Update Not Working

S

sam

I wanna perform an update but SQL SVR do nothing

But when I perform at T-SQL at Query Analyzer it is working OK.

ASP.Net 1.1 Coding
----------------------
Dim constrUpdate As String = "server='SQLSVR';
Database='JDE_ERP_ARCHIVAL'"
Dim sqlconUpdate As System.Data.SqlClient.sqlconnection
= New System.Data.SqlClient.sqlconnection(constrUpdate)
Dim sqlcmdUpdate As System.Data.SqlClient.SqlCommand =
New SqlCommand()
Dim sqldaUpdate As New
system.Data.SqlClient.sqldataAdapter()

Try
sqlcmdUpdate = sqlconUpdate.CreateCommand
sqlcmdUpdate.CommandText = "update
Rpt_WH_Result_W1_FG set glclass = dim_item.gl_category from
Rpt_WH_Result_W1_FG
, dim_item where
Rpt_WH_Result_W1_FG.illitm
= dim_item.item_number_nk"

sqldaUpdate.SelectCommand = sqlcmdUpdate

sqlconUpdate.Open
sqlcmdUpdate.ExecuteNonQuery
Finally
sqlconUpdate.Close()
sqlconUpdate.Dispose()
End Try

constrUpdate = Nothing
sqlconUpdate = Nothing
sqlcmdUpdate = Nothing


Please advise.

Many thanks.
 
C

Cor Ligthert

sam,

What you can do is adding a catch block in your try blocks.
In that you write something as
catch ex as exception
response.write(ex)

(In your production situation you can better write this to a log)

What has nothing to do with your problem however about your code, there is
no reason to close *and* to dispose your connection. Better is dispose
because that this one is overloaded to remove the internal connectionstring
in 1.x.

Setting the objects to nothing has not any result than some (very few) used
nanoseconds. In a webpage it is the last totally unnecessary because
everything is removed when the program ends. (A webpage is not persistent)

I hope this helps.

Cor
 
W

W.G. Ryan eMVP

You probably want to redo this from scratch. If you use the DataAdapter
configuration wizard, it will write the code for you the first time and you
can see what it writes . But if you look at the values going into Sql Server
(From profiler - I'll be it's not what you expect).

What I'm guessin gyou want to do is update all of the rows that have been
changed, in that case DataAdapter.Update(DataTable) is the preferred method.
 

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