update syntax

tiffany

Well-known member
Joined
Aug 7, 2005
Messages
57
Programming Experience
1-3
Hi, I had syntax error in the update command. I wrote this:


Dim strConn AsString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & Server.MapPath("movie.mdb")

Dim strSQL AsString = "UPDATE movieDet SET Title = '" + tb_title.Text + "', price = '" + tb_np.Text + "', des = '" + tb_desc.Text + "', Year = '" + tb_yr.Text + "', actor1 = '" + tb_ac1.Text + "' ,actor2 = '" + tb_ac2.Text + "',actor3 = '" + tb_ac3.Text + "', actor4 = '" + tb_ac4.Text + "', branch = '" + ddl_bra.SelectedValue + "',section = '" + ddl_sec.SelectedValue + "',category = '" + ddl_cat.SelectedValue + "', type = '" + ddl_type.SelectedValue + "', pic = '" + Image1.ImageUrl + "' Where MovieID = '" + tb_id.Text + "' "

Dim scnnNW AsNew OleDbConnection(strConn)

Dim scmd AsNew OleDbCommand(strSQL, scnnNW)

Dim dr As OleDbDataReader

Try

scnnNW.Open()

dr = scmd.ExecuteReader()

dr.Close()

Response.Write("Product successfully saved to the database.")

Catch
exp As Exception

Response.Write("Error: " & exp.Message)

Finally

scnnNW.Close()

EndTry

I had check several times for the data type, the syntax but it seems like fine. Can anyone help?

thnkx
 
some of your field names are reserved SQL words... like Type and Year for instance.... put brackets [] around the field names (like this: [Year]) ... that should clear up the problem.

And as far as I can tell, those are the only two that should need it.

-tg
 
Dim scmd AsNew OleDbCommand(strSQL, scnnNW)

Try

scnnNW.Open()

scmd.ExecuteNonQuery

Response.Write("Product successfully saved to the database.")

Catch
exp As Exception

Response.Write("Error: " & exp.Message)

Finally

scnnNW.Close()

EndTry
 
Hi, sorry to create lots of trouble. But it still have the syntax error in update statment. I response.write srtSQL after the scnnNW.open. it said that "Error: Thread was being aborted."

What does this mean?
 
Back
Top