Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

should this work in SQL Server 2000

Status
Not open for further replies.

sthmpsn1

MIS
Sep 26, 2001
456
US
Should this statement work in SQL Server 2000. I run this code on my local server which is running SQL Server 7.0, but if I run it on my web hosting server which is 2000 it doesn't update. I get no error messages, but it doesn't update. Comments.text is a textbox on my page with multiple lines.
Dim strInsert As String
Dim cmdInsert As SqlCommand

Dim dbconn1 As SqlConnection = New SqlConnection("server=server;database=am1stdb;uid=userID;password=password")
strInsert = "update apply4 Set comments=@comments where ID ='34'"
cmdInsert = New SqlCommand(strInsert, dbconn1)
cmdInsert.Parameters.Add("@comments", comments.Text)

dbconn1.Open()
cmdInsert.ExecuteNonQuery()
dbconn1.Close()
 
Why do you have single quotes around the 34? Is the ID field a string field? If not, try without the single quotes (shot in the dark, and I can't see sql server 7 using single quotes around numerics...but strange nevertheless)

If you're not getting any errors back, its the only thing that I can see that might be wanky (can't find the string '34' in the field, so it never does the update)

D'Arcy
 
I changed it to this

"update apply4 Set comments= @comments where ID = 34 "

and it still doesn't update
 
You should really consider using a stored procedure for this types of calls.... giving you the ability to tweak stored procedures without having to open your front-end code.

you could try this...


strInsert = "update apply4 Set comments="+comments.Text+"where ID =34"
 
You might need to tell it that it is a text type command object, although I doubt that is the case.
 
It is something funky in the code, I rebuilt the page and am using the same update statement and it works, It has to be something somewhere else in the .net app that made it not update. Wierd!

Thanks for all the help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top