p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP Databases (http://p2p.wrox.com/forumdisplay.php?f=62)
-   -   Trouble executing SQL statement (http://p2p.wrox.com/showthread.php?t=31094)

turbo_rabbit July 1st, 2005 03:12 PM

Trouble executing SQL statement
I an very new to ASP (this week to be exact, been doing Coldfusion), and so far I have liked coding with it. Anyway here is my problem.

I am tring to do an insert statement with the following code:
(this it all the code on the page)


   var AddJob = Server.CreateObject("ADODB.Recordset");
   AddJob.ActiveConnection = MM_nafpinc_DSN_STRING;
   strsql ="INSERT INTO members (DateAdd,JobTitle,JobDescription) VALUES ('7/1/2005','Test','test')"

   AddJob.Execute strsql

   <% Response.Write(strsql) %>

Here is the error that is generated when I try to load the page:

    Microsoft JScript compilation error '800a03ec'

    Expected ';'

    /nafpinc/_admin/employment-act.asp, line 15

    AddJob.Execute strsql

I have tried putting in the ';', but I still receive the same error message.

om_prakash July 3rd, 2005 02:41 AM

Please modify
AddJob.Execute strsql
AddJob = MM_nafpinc_DSN_STRING.Execute(strsql)

Om Prakash

turbo_rabbit July 6th, 2005 09:11 AM

I Tried your suggestion and this was the error that I received:

   Microsoft JScript runtime error '800a01b6'

   Object doesn't support this property or method

   /nafpinc/_admin/employment-act.asp, line 9

om_prakash July 6th, 2005 09:27 AM


Can you provide the details, to which line u are getting error:

Any special reason to use javascript as server side..?

Om Prakash

mkayombo July 6th, 2005 09:49 AM

correct me if wrong,

The date value should be enclosed with hash

ChrisScott July 6th, 2005 10:13 AM

You are running an insert query and therefore do not need a recordset object, these are used when getting records out of a db.
You need to create a connection object and then use the Execute() method of that.
The expected ";" error is probably the line AddJob.Execute strsql - in javascript you need to surround method parameters with parenthesis e.g. AddJob.Execute(strsql)
Something like the following should work...

var conn = Server.CreateObject("ADODB.Connection");
var strsql ="INSERT INTO members (DateAdd,JobTitle,JobDescription) VALUES ('7/1/2005','Test','test');";

Like mkayombo says, you may need to surround the date with hash signs, but this is only applicable to some databases e.g. Access



turbo_rabbit July 6th, 2005 01:30 PM


That worked perfectly. Thanks everybody for all your help.

All times are GMT -4. The time now is 04:57 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.