views:

43

answers:

2
' Setting variables
 Dim con, sql_insert, data_source

 data_source = "project_db"
 sql_insert = "insert into cart ( UserID,Count,ProductName,ProductDescription,ProductPrice) values ('"&user_id&"','"&count&"','"&product_name&"','"&product_description&"','"&product_price&"')"

 ' Creating the Connection Object and opening the database
 Set con = Server.CreateObject("ADODB.Connection")
 con.Open data_source

 ' Executing the sql insertion code
 con.Execute sql_insert

 ' Done. Now Close the connection
 con.Close
 Set con = Nothing

AS you can see , it is a simple code . and it worked in my local host for 5 or 6 times. but now it didn't work. What's the problem ? I think , it's about my database or memory. i setup 2 different iis in 2 different computer and they behave same... please help..

Thanks

A: 

Does it give you any error message? Make sure all the values you are inserting actually have values and are not blank or null. You can check this by response.write all the values and then response.end to see if they contain any values.

Tom Gullen
A: 

I bet it's a data-dependent error. You should be using ADO parameters. Those will ensure that extraneous SQL-unfriendly characters in your input do not adversely affect your database operation. You should also use them to guard against SQL injection issues.

Some docs are available at http://msdn.microsoft.com/en-us/library/ms675869(VS.85).aspx, and you can google for "ADO parameters" and find many relevant examples.

Chris Farmer