Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 1st, 2005, 03:12 PM
Authorized User
 
Join Date: Jul 2005
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.
 
Old July 3rd, 2005, 02:41 AM
Friend of Wrox
 
Join Date: May 2004
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
 
Old July 6th, 2005, 09:11 AM
Authorized User
 
Join Date: Jul 2005
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
 
Old July 6th, 2005, 09:27 AM
Friend of Wrox
 
Join Date: May 2004
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
 
Old July 6th, 2005, 09:49 AM
Registered User
 
Join Date: Jun 2005
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')

 
Old July 6th, 2005, 10:13 AM
Friend of Wrox
 
Join Date: Jul 2003
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
 
Old July 6th, 2005, 01:30 PM
Authorized User
 
Join Date: Jul 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Chris,

That worked perfectly. Thanks everybody for all your help.





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





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