Re: DataGrid problem.
From: Integer Software (usenet_at_fub-group.de)
Date: 08/19/04
- Next message: xtremetester: "EXE PROTECTION / TESTING FREE !!! / UNCRACKED PROMISE"
- Previous message: One Handed Man \( OHM - Terry Burns \): "Re: VB.NET to c# convert"
- Next in thread: Integer Software: "Re: DataGrid problem."
- Maybe reply: Integer Software: "Re: DataGrid problem."
- Maybe reply: Integer Software: "Re: DataGrid problem."
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 19 Aug 2004 19:07:48 +0200
Hello. Does MSDN not entitle me to an answer here within a certain amount of
time or is this not one of the managed newsgroups?
Anyway, I have come a little further by taking ktadno out of the dataset. It
should still get saved as ktadno is still present as a parameter in the
Insert and Update statements of the DataAdapter. I can now at least fill
in my dataset from the grid without any errors.
However when saving the dataset to the database I have a new error. This is
what my saving code looks like:
// Store record
try
{
int biggest =0;
foreach(DataRow dr in dsBankVerbindungen1.ktpfrec.Rows)
{
if (dr["KTLFDN"]!= DBNull.Value && Convert.ToInt16(dr["KTLFDN"]) >
biggest)
biggest = Convert.ToInt16(dr["KTLFDN"]);
}
foreach(DataRow dr in dsBankVerbindungen1.ktpfrec.Rows)
{
if (dr["KTLFDN"]==DBNull.Value)
dr["KTLFDN"] = ++biggest;
}
oleDbDataAdapter7.Update(dsBankVerbindungen1);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
Now I need to set this KTLFDN manually as its not required for the user to
enter it in the datagrid, and indeed it is not even present in the
datagrid. KTLFDN is a parameter in the DataAdapters Insert and Update
statements, and the above code gives me the error "Parameter?_6 has no
Standard Value" (thats a translation from the german error message). And I
get a Red circle with an exclamation mark next to the first row in the
datagrid.
If I then take KTLFDN out of the Insert commands list of parameters, the
above code gives me the error "For at least one of the necessary
Parameters, no value was given". And I get the exclamation mark.
Now from the OleDbParameter Collection Editor, I see that most of my fields
are bound to columns in the DataGrid. KTADNO is set one time before the
DataAdapter is used, since KTADNO is the same for every row in this
instance of the DataGrid. But KTLFDN is different for each row in the
dataset.
How do I ensure that the parameter does not have a fixed value, and is not
bound to a column, but instead gets its value from the dataset?
Thanks a lot
Kurt
Integer Software
PS Please reply in newsgroup as email address is a spamcatcher.
Integer Software wrote:
> Hi.
> I have a simple datagrid on a form, bound to a database.
>
> The dataset that the datagrid is bound to is initialized as follows:
>
> dsBankVerbindungen1.Clear();
> oleDbDataAdapter7.SelectCommand.Parameters["KTADNO"].Value =
> currentRecord;
> //oleDbDataAdapter7.DeleteCommand.Parameters["KTADNO"].Value =
> currentRecord; oleDbDataAdapter7.InsertCommand.Parameters["KTADNO"].Value
> = currentRecord;
> oleDbDataAdapter7.UpdateCommand.Parameters["KTADNO"].Value =
> currentRecord; oleDbDataAdapter7.Fill(dsBankVerbindungen1);
>
> Now the datagrid has 4 columns on it. KTADNO is like a foreign key to
> another database and is hidden from the user and thus not on the datagrid.
>
> Now when someone fills in the 4 columns, and moves to another row, I get
> an error message like "The 'KTADNO' column may not contain and null
> values- Would you like to correct this value?"
>
> Now its true, that column may not contain nulls, but how can there be a
> null in there? Its a parameter not even related to the datagrid columns,
> it has been set in the InsertCommand and UpdateCommand above.
>
> Have I missed something? Is there anyway I can "trap" whatever displays
> the error message, and preempt it, setting the value of KTADNO manually?
> Or whats the canonical MS way of doing this?
>
> I am a MSDN Universal customer by the way.
>
> Thanks
>
> Kurt
> Integer Software
>
> PS Please reply in the newsgroup as the email address is just a
> spamcatcher.
- Next message: xtremetester: "EXE PROTECTION / TESTING FREE !!! / UNCRACKED PROMISE"
- Previous message: One Handed Man \( OHM - Terry Burns \): "Re: VB.NET to c# convert"
- Next in thread: Integer Software: "Re: DataGrid problem."
- Maybe reply: Integer Software: "Re: DataGrid problem."
- Maybe reply: Integer Software: "Re: DataGrid problem."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|