dataadapter UPDATE INSERT parameters

  • Thread starter Thread starter John Smith
  • Start date Start date
J

John Smith

i dont understand how to use `em
all those @id ...
what they have to do with a datagrid bound to a dataset filled by an adapter

TIA
 
Hi John,

You can replace them with values something as this
cmd.Parameters.Add(New SqlParameter("@ID", SqlDbType.NVarChar, 10)).Value =
"Cor"

when you update them you have to remove them first

I hope this helps

Cor
 
If you look at the overload for a Parameter construtor, there is support for
the sourceColumn. When the dataadapter has its Update method called, it
walks through the datatable checking for rows with Rowstate or
Added/Deleted/Modified. It does this one at a time. If it sees a rowstate
of added, it uses the Insert Command. If it's deleted, it uses the Delete
Command and if it sees Modified it uses Update command. Remember it does
this one at a time. So both the commandbuilder and the DataAdapter
Configuration wizard add the parameters in advance. The commandbuilder
infers them from the Select statement...the Wizard builds them in the
designer. Instead of adding the parameters each time through, the
dataAdapter just uses the values in the DataTable when it's calling a
command, and uses the SourceColumn to know what value to use. This way it
knows the original value and new one so it can handle the concurrency
scenario.

So instead of looping through and adding params each time, it just adds them
at the beginning and changes the params value at each pass.

HTH,

Bill

For further reading, I have a few articles here:
http://msdn.microsoft.com/library/d...systemdatasqlclientsqlparameterclasstopic.asp
http://www.knowdotnet.com/articles/parametergotcha.html
 
Back
Top