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!!!
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!!!