problem passing perameter in insert command genareted by SqlCommandBuilder
-
Thursday, September 13, 2012 11:49 AM
I have genareted insert command using sqlcommandbuilder ...
need to pass some perameter with the that command ...
I have write something like ...
SqlDataAdapter adepter = new SqlDataAdapter("select * from " + destinationtablename + "_errors", sqlcon);
SqlCommandBuilder sbc = new SqlCommandBuilder(adepter);
adepter.InsertCommand = sbc.GetInsertCommand();
adepter.InsertCommand.Parameters.AddWithValue("@Run_id", DXC_run_id);SqlDataAdapter adepter = new SqlDataAdapter("select * from " + destinationtablename + "_errors", sqlcon); SqlCommandBuilder sbc = new SqlCommandBuilder(adepter); adepter.InsertCommand = sbc.GetInsertCommand(); adepter.InsertCommand.Parameters.AddWithValue("@Run_id", DXC_run_id);
It works fine when i call
adepter.Update(dt);
but there is no value for Run_id column in row in the table...
- Changed Type Bob Wu-MTMicrosoft Contingent Staff, Moderator Monday, September 17, 2012 5:54 AM
All Replies
-
Friday, September 14, 2012 8:50 AMModerator
Hi .netaholic,
I think this issue occurs because the Insert command Text doesn't contains @Run_id.
For more details, see the example in the link below.
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.parameters.aspx
Bob Wu [MSFT]
MSDN Community Support | Feedback to us
- Marked As Answer by Bob Wu-MTMicrosoft Contingent Staff, Moderator Tuesday, September 25, 2012 2:50 AM

