A couple of questions about updating data through a dataset



I have been using .NET for three years. We are currently using VS .NET 2003
and SQL Server 2000. Whenever I have needed to update data I normally
created a SqlCommand object, assigned it the appropriate string (depending
upon whether it is a stored procedure or not) and executed it. However, now
I would like to use the SqlDataAdapter's UpdateCommand and Update() method.

However, I am running into problems, which I think I can break down into two
questions. The first is, how do I assign values to the dataset which I want
to be updated? For example, if I have something like this:

DataRow r = DataTable.Rows[0];

and the row has a column named FirstName, can I do this:

r["FirstName"] = "Rod";

or do I have to do something like this first:

r.BeginEdit();
r["FirstName"] = "Rod";

And if I do have to use the BeginEdit() method, do I also have to issue the
EndEdit() method? Or will that basically clear the row's Current view and
reassign that to the Original view?

I know that the datarow's SourceVersion will come into play, but I am not
sure how.

Second question: What DOES the Update() method of the SqlDataAdapter really
work on? For example, after struggling with this for half the day I finally
got rid of the error message I was getting saying,

"Procedure 'spMyProc' expects parameter '@FirstName', which was not
supplied"

to go away, but now when I assign a value to the datarow's FirstName column,
then I would have expected that to actually be saved to the database when I
issued the SqlDataAdapter's Update() method. Instead, it just quietly goes
about its business and nothing at all is saved/updated. So, what I am doing
wrong now?

Rod


.



Relevant Pages

  • Re: curve fit with daqmx
    ... Curve Fitting express VI and select ?open front panel?, ... After you have done this you will have access to the string control ... Now for you second question: I have a question who is ... functions pallete curve.png: ...
    (comp.lang.labview)
  • Re: char *s = "Google"
    ... CBFalconer wrote: ... where this string "google"will be stored? ... So re-posting the second question is reasonable. ...
    (comp.lang.c)
  • RE: how long can a string be
    ... Second question, I need to be able to find a certain character in the ... I use InderOf to fine this character in a string. ... >> I'm receiving info from a com port into a string. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: A way to select first 15 words from a string
    ... > If the answer is NO, there is a second question: ... > If there is no function to do it, do you think it is ok to implode the ... > string and then just count out the first 'x' number of words you want? ... PHP's substr() function does exactly what you need: ...
    (alt.php)