We help IT Professionals succeed at work.

godaddy - insert query could not execute

Loganathan Natarajan
on
I am using godaddy site and trying to do insert with the below code.

The same code is used to select the records and it is working fine. Why the insert statement is not executed on the code.

Thanks
sqlinsert = "insert into enquiry(inq_name, inq_comp, inq_email, inq_phone, inq_address, inq_city, inq_state, inq_zip, inq_country, inq_products, inq_submitted) values ('"&replacequote(strname)&"', '"&replacequote(strcompany)&"', '"&replacequote(stremail)&"',  '"&replacequote(strphone)&"', '"&replacequote(straddress)&"','"&replacequote(strcity)&"', '"&replacequote(strstate)&"', '"&replacequote(strzip)&"', '"&replacequote(strcountry)&"', '"&replacequote(strHTML)&"','"&strdatetime&"')"
				
				'response.Write(sqlinsert)				
				'response.End()
				set rs_product2=server.CreateObject("adodb.recordset")
				rs_product2.Open sqlinsert,con,1,1

Open in new window

Comment
Watch Question

Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
Are you doing a 'SELECT' just before this?  Maybe the database connection is already open?

Author

Commented:
no, i am not doing select before.
I just open the connection and wants to insert query?

db is already closed?
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
I don't know but that's part of what I'm trying to find out.  Try the code below without the 1's at the end.  The second line is to close the connection when you're done.
rs_product2.Open sqlinsert,con
Set rs_product2 = nothing

Open in new window

Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
That code assumes that 'con' is a connection string that you have already defined before that code.
Senior Systems and Integration Developer
Commented:
Presumably you are getting some kind of error, knowing what it is would be helpful.

Odds are it's either a syntax error or a permissions error.

Author

Commented:
thanks