Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics 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, 12:06 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:

    <%
    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
    %>

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 1st, 2005, 12:15 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

You have a JavaScript error somewhere in your script. It is not referring to your Insert.

 
Old July 1st, 2005, 01:06 PM
Authorized User
 
Join Date: Jul 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Like I said I am new so if you could point out my error I would appreiate it. I don't see where there can be an error in my script when other than the connection string that is the only code on the page.

The following is the code for the entire 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
//qDeleteJob.CursorType = 0;
//qDeleteJob.CursorLocation = 2;
//qDeleteJob.LockType = 1;
//**leave comment** qDeleteJob.Open();
//var qDeleteJob = 0;
%>

<% Response.Write(strsql) %>

There is nothing wrong with the "nafpinc_DSN.asp" file. It is used on all my other pages and works fine.
 
Old July 1st, 2005, 01:10 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Seems you are using classic ASP code. This is .NET forum. Are you creating a .asp or .aspx page?

 
Old July 1st, 2005, 02:10 PM
Authorized User
 
Join Date: Jul 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Actually if you look at the title of this forum says "ASP and ASP.NET".

Anyways.. I am creating a .asp page.
 
Old July 1st, 2005, 02:16 PM
Authorized User
 
Join Date: Jul 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I See my bad I am in the ASPX section. Can you still help?

 
Old July 1st, 2005, 02:19 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

I am more familiar with .NET. Perhaps you will get a better and quicker response from on of the ASP forums.

 
Old July 1st, 2005, 02:33 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You are missing ; on the end of the following statements.

strsql ="INSERT INTO members (DateAdd,JobTitle,JobDescription) VALUES ('7/1/2005','Test','test')"
AddJob.Execute strsql
 
Old July 1st, 2005, 02:40 PM
Authorized User
 
Join Date: Jul 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In my original post I said I tried that and still got the same error message.
 
Old July 5th, 2005, 09:53 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Ok, my bad.

The compiler is probably seeing "AddJob.Execute" without the () and expecting a following ";". Perhaps then the Execute method needs ( )?

AddJob.Execute(strsql);

-Peter





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 Classic ASP Databases 6 July 6th, 2005 01:30 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.