SQL Active Sever Pages

Posted on 2006-05-28
Last Modified: 2008-02-20
I need  your help, please!

I've been using JavaScript for all my asp pages for this project, and just found out that my form E-mail only works with VBScript, so now I have to convert all my JavaScript to VBScript; I don't think  I can use both languages on the same page, right?

I have two asp pages, Sending.asp and Receiving.asp. The Sending.asp form posts to Receiving.asp thenv inserted the data into an access database, that's where I have the SQL Insert statement in receiving.asp.

Anyway here is my question/problem;  I'm getting this error message with my sql insert statement, I'm no expert with SQL stuff so I need your hlep. I would really really appriciate any help I can get.

Here is the error message:

Microsoft VBScript compilation error '800a0401'

Expected end of statement

/EmailConfirmTest.asp, line 12

con.Open "PROVIDER=SQLOLEDB;DATA SOURCE=D:\\myhost\\myweb\\Database\\mydatabasename.mdb");

And here is my SQL statement I have on my receiing page:

Dim sql_insert, con, LN, FN

SET con = Server.CreateObject("adodb.connection")

con.Open "PROVIDER=SQLOLEDB;DATA SOURCE=D:\\myhost\\myweb\\Database\\mydatabasename.mdb")

LN = Replace(Request.Form("CRLastName"),"'","''")
FN = Replace(Request.Form("CRFirstName"),"'","''")

sql_insert = "insert into mytable(CRLastName, CRFirstName) values( '" & LN & "','" & FN & "' )"
con.Execute (sql_insert)

SET con = Nothing
Question by:lazzydog
    LVL 95

    Accepted Solution

    You put the closed quote in the wrong place - use:
    con.Open "PROVIDER=SQLOLEDB;DATA SOURCE=D:\\myhost\\myweb\\Database\\mydatabasename.mdb);"

    Author Comment

    Tried that and got an invalide authorization specification, any ideas what that is?

    Microsoft OLE DB Provider for SQL Server error '80040e4d'

    Invalid authorization specification

    /ConfReg2006Confirm_EmailTest.asp, line 35

    LVL 95

    Expert Comment

    by:Lee W, MVP
    Line 35 is a different line, so you have another error.

    And you haven't posted the code of that page in and around line 35.

    Author Comment

    Actually I was testing it on a different page. Sorry about that. Tested on that same page and got same error message.

    Microsoft OLE DB Provider for SQL Server error '80040e4d'

    Invalid authorization specification

    /EmailConfirmTest.asp, line 12

    this is what I have on line 12
    con.Open "PROVIDER=SQLOLEDB;DATA SOURCE=D:\\shome\\myweb\\Database\\mydatabasename.mdb);"
    LVL 95

    Expert Comment

    by:Lee W, MVP
    Try using this, substituting appropriate information for your situation:

    Con.Open "DBQ=" & Server.MapPath("database.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};DriverId=25;MaxBufferSize=8192;Threads=20;", "username", "password"

    Modified slightly from the sample here:

    LVL 75

    Assisted Solution

    by:Anthony Perkins
    >>con.Open "PROVIDER=SQLOLEDB;DATA SOURCE=D:\\shome\\myweb\\Database\\mydatabasename.mdb);"<<
    You do not need to escape your \ using VBScript like you do in JavaScript.

    Author Comment

    Thanks for you guys input, it turned out I got the script to work with javascript. But I'm going to give you guys points anyway for the input.

    Featured Post

    Gigs: Get Your Project Delivered by an Expert

    Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Split columns - Power Query 2 65
    cleaning xml string 2 39
    Determining if Request.Form is empty 1 37
    SQL Filter Question 8 58
    I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
    I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now