N
newsgroups1
Hi All,
Strange problem, but I didn't find a solution:
I created a C# Form. Because it's some easy stuff to handle here, I
used the drag-n-drop-Function to create DataConnection, DataSet &
DataAdapter.
So far, so well.
Update and Delete functions work fine. BUT the Insert function won't
do it's work as expected.
Here's a code-snippet:
<snip>
private void Broadcast_Load(object sender, System.EventArgs e)
{
if(Broadcast_Key > 0)
{
button11.Text = "Update";
daBCast.SelectCommand.Parameters["@Broadcast_Key"].Value =
Broadcast_Key;
daBCast.Fill(dsBcast1);
}
cm1 = (CurrencyManager) this.BindingContext[dsBcast1, "Broadcast"];
if(Broadcast_Key < 0)
{
button11.Text = "Insert";
cm1.AddNew();
}
}
private void clickSave(object sender, System.EventArgs e)
{
this.daBCast.InsertCommand.Parameters["@FK_Client_Key"].Value =
Client_Key;
cm1.EndCurrentEdit();
if(dsBcast1.HasChanges())
{
try
{
int m = daBCast.Update(dsBcast1.Broadcast);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
this.Close();
}
</snap>
IMHO, the Update command should now have the correct Parameter in it.
Isn't it?
Well, when debugging this line-by-line, the @FK_Client_Key has always
the correct value. BUT when inserting the values in the database, the
value inserted is 0. No idea why...
In the database the FK_Client_Key has a foreign key constraint to
another table.
The variable Client_Key is a int variable. And it really has (the
correct) value.
Any help would be appreciated !
Regards,
Marc
Strange problem, but I didn't find a solution:
I created a C# Form. Because it's some easy stuff to handle here, I
used the drag-n-drop-Function to create DataConnection, DataSet &
DataAdapter.
So far, so well.
Update and Delete functions work fine. BUT the Insert function won't
do it's work as expected.
Here's a code-snippet:
<snip>
private void Broadcast_Load(object sender, System.EventArgs e)
{
if(Broadcast_Key > 0)
{
button11.Text = "Update";
daBCast.SelectCommand.Parameters["@Broadcast_Key"].Value =
Broadcast_Key;
daBCast.Fill(dsBcast1);
}
cm1 = (CurrencyManager) this.BindingContext[dsBcast1, "Broadcast"];
if(Broadcast_Key < 0)
{
button11.Text = "Insert";
cm1.AddNew();
}
}
private void clickSave(object sender, System.EventArgs e)
{
this.daBCast.InsertCommand.Parameters["@FK_Client_Key"].Value =
Client_Key;
cm1.EndCurrentEdit();
if(dsBcast1.HasChanges())
{
try
{
int m = daBCast.Update(dsBcast1.Broadcast);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
this.Close();
}
</snap>
IMHO, the Update command should now have the correct Parameter in it.
Isn't it?
Well, when debugging this line-by-line, the @FK_Client_Key has always
the correct value. BUT when inserting the values in the database, the
value inserted is 0. No idea why...
In the database the FK_Client_Key has a foreign key constraint to
another table.
The variable Client_Key is a int variable. And it really has (the
correct) value.
Any help would be appreciated !
Regards,
Marc