Why does my Update not update?

  • Thread starter Thread starter Bruce A. Julseth
  • Start date Start date
B

Bruce A. Julseth

After running the follow code, "intResult" is returned as "0" and the update
does not take place. Could it be that my database column name, "Name", is
not being related to the Procedure parameter, "@Name?" Is so, what do I need
to change so that "Name" will be related to "@Name?". Can I do it without
using a "SqlParameter?"

Dim drData As DataRow
drData = dstMyName.Tables("MyName").NewRow

drData("Name") = txtName.text

Dim intResult As Integer

With daMyName
.InsertCommand = New SqlCommand()
With .InsertCommand
.CommandText = "InsertDataRecords"
.CommandType = CommandType.StoredProcedure
.Connection = cnnMyName
End With

intResult = .Update(dstMyName, "MyName")

Thank you...

Bruce
 
Hi Bruce,

Before updating database, you should add the 'new row' to
datatable:

'...
drData("Name") = txtName.text
' Add the row to datatable
dstMyName.Tables("MyName").Rows.Add(drData)

Dim intResult As Integer
'...

HTH

Elton Wang
(e-mail address removed)
 
Okay!! I thought "drData = dstMyName.Tables("MyName").NewRow" also added the
new row.

Thank you very much..

Bruce
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top