Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 1st, 2005, 03:12 PM
Authorized User
 
Join Date: Jul 2005
Location: Mishawaka, IN, USA.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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)

   <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>


   <%
   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.
Reply With Quote
  #2 (permalink)  
Old July 3rd, 2005, 02:41 AM
Friend of Wrox
Points: 2,473, Level: 20
Points: 2,473, Level: 20 Points: 2,473, Level: 20 Points: 2,473, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2004
Location: India
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

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


Om Prakash
Reply With Quote
  #3 (permalink)  
Old July 6th, 2005, 09:11 AM
Authorized User
 
Join Date: Jul 2005
Location: Mishawaka, IN, USA.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Reply With Quote
  #4 (permalink)  
Old July 6th, 2005, 09:27 AM
Friend of Wrox
Points: 2,473, Level: 20
Points: 2,473, Level: 20 Points: 2,473, Level: 20 Points: 2,473, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2004
Location: India
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Hi,

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

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




Om Prakash
Reply With Quote
  #5 (permalink)  
Old July 6th, 2005, 09:49 AM
Registered User
 
Join Date: Jun 2005
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

correct me if wrong,

The date value should be enclosed with hash
(#7/1/2005#,'Test','test')

Reply With Quote
  #6 (permalink)  
Old July 6th, 2005, 10:13 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

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...
Code:
var conn = Server.CreateObject("ADODB.Connection");
conn.Open(MM_nafpinc_DSN_STRING);
var strsql ="INSERT INTO members (DateAdd,JobTitle,JobDescription) VALUES ('7/1/2005','Test','test');";
conn.Execute(strsql);
Like mkayombo says, you may need to surround the date with hash signs, but this is only applicable to some databases e.g. Access

HTH,

Chris
Reply With Quote
  #7 (permalink)  
Old July 6th, 2005, 01:30 PM
Authorized User
 
Join Date: Jul 2005
Location: Mishawaka, IN, USA.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Chris,

That worked perfectly. Thanks everybody for all your help.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble Using For Next Statement slbibs ASP.NET 2.0 Professional 9 September 19th, 2008 09:44 AM
Trouble with IF statement jazzcatone Classic ASP Basics 1 October 19th, 2005 04:43 AM
Trouble executing SQL statement turbo_rabbit ASP.NET 1.0 and 1.1 Basics 13 July 6th, 2005 01:31 PM
Trouble with SQL statement jsanders ASP.NET 1.0 and 1.1 Basics 1 May 24th, 2005 03:11 PM
Trouble with mysql statement cbright JSP Basics 1 October 2nd, 2003 06:22 AM



All times are GMT -4. The time now is 04:51 AM.


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