SQL Data Adapter Will not update from ASP.net -- VB

S

Steve Wolfie

I have an asp.net application in which users need to fill in a form.
Sometimes they do not have all the info to fill all fields. Since they do
not always have the complete info, we need to have them come back, pull the
existing fields from the database, and then perhaps add and / or edit some
of the fields.

The initial INSERT command works wonderfully. However, the update goes bad.
Follows the architecture:

for initial insertion into sql server table is pretty much:

************************************************
Sub Submit_click
sqlcn.open()
sqlda.insertcommand.parameter("@field1").value = txtfield1.text
sqlda.insertcommand.parameter("@field2").value = txtfield2.text
sqlda.insertcommand.ExecuteNonQuery()
sqlcn.close()
End Sub
*************************************************

For updates / review -- NOTE: the select statement is designed to return
only one row, as "id" is the primary key on this table.

*************************************************
Sub on_pageload()
sqlda.selectcommand.commandtext = "SELECT * FROM table WHERE id = ('" &
Request.querystring("id") & "')"
sqlcn.open()
sqldataadapter.fill(MyDataSet)
sqlcn.close()
txtfield1.text = MyDataSet.tables(0).rows(0).item(1)
txtfield2.text = MyDataSet.tables(0).rows(0).item(2)
End Sub

Sub Submit_clicked()
MyDataSet.tables(0).rows(0).item(1) = txtfield1.text
MyDataSet.tables(0).rows(0).item(2) = txtfield2.text
sqlcn.open()
sqlda.update(MyDataSet)
sqlcon.close()
Response.redirect(http://MyIntranetServer/Page.aspx)
End Sub
**************************************************

THIS DOES NOT UPDATE THE TABLE IN SQL.... There is no error or exception.
The page redirects as instructed. The fields in sql simply do not update. I
cannot understand why. I have another ASP.NET app that does something
similar, where a workorder comes in and obviously, the data from that row
needs to be updated, when a tech puts in some notes on the case. i have
examined the code closely, and it is almost freaking identical. I use the
same type of procedure.

WHY?? PLEASE HELP!!! I will be happy to give (real) source to anyone who
wants to help!! Maybe there is a more efficient way to do what I am trying
to do.

I am just learning....

Thanks a TON!!!
 
D

David Lloyd

Steve:

It would be interesting to see the SQL for the UpdateCommand of your
DataAdapter. The posted code so far does not show any reference to it.


--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.
 
S

Steve Wolfie

It would be interesting to see the SQL for the UpdateCommand of your
DataAdapter. The posted code so far does not show any reference to it.

It is not needed when using the dataset... Correct?

I am manually changing the data in the dataset and then using that to update
the sql data adapter.

So...... i do not need to call the update command.

Please help!!!
 
D

David Lloyd

Steve:

But it is the DataAdapter that does the updating in the database, not the
DataSet, i.e. DataAdapter.Update. How does the DataAdapter know what to
update if there is no update command?

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.
 
S

Steve Wolfie

Dave:

Can I email you the source? I do not wish to post it here.

I am not using sqldataadapter.updatecommand.executenonquery()

I am calling sqldataadapter.update(DataSet)

it is my understanding that this does not use the commandtext of
selectcommand

Thanks...
 

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

Top