Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: =?Windows-1252?Q?Re:_=5Baccess=5Fasp=5D_Chapter_14_Try_It_Out_#5_=96_Pass? =?Windows-1252?Q?ing_values_to_an_Access_action_stored_procedure?=


Message #1 by "Ken Schaefer" <ken@a...> on Wed, 10 Apr 2002 16:47:11 +1000
Change:

: objCmd.CommandType = adCmdText

to

objCmd.CommandType = adCmdStoredProc

The error is being caused because you are telling ADO that you are passing a
literal SQL statement to be executed by the database engine. Such statements
need to begin with INSERT, SELECT, DELETE or UPDATE.

Also, you should have the line:

<% Set objCmd = Nothing%>

after you execute the command.

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Matt Hall" <matt_f_hall@h...>
Subject: [access_asp] Chapter 14 Try It Out #5 ? Passing values to an Access
action stored procedure


: Hi there,
:
: I changed the connection from DSN (which works) to OLE DB (which doesn't
: for me?)
:
: The Error
:
: Description: Invalid SQL statement;
: expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.
:
: Source: Microsoft JET Database Engine
:
: How do I get code work with an ole db connection?
:
: Here is the query code
:
: PARAMETERS Name Text ( 255 ), Class Text ( 255 ), Launched DateTime,
: Certified Bit, Notes Text, [Value] Currency;
: INSERT INTO Boats ( BoatName, BoatClass, BoatLaunched, BoatCertified,
: BoatNote, BoatValue )
: SELECT [Name] AS Expr1, [Class] AS Expr2, [Launched] AS Expr3, [Certified]
: AS Expr4, [Notes] AS Expr5, [Value] AS Expr6;
:
: Here is the ASP main code
:
: 'Create and open the database object
: Set objConn = Server.CreateObject("ADODB.Connection")
:
: objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
: & Server.Mappath("../databases/sailors.mdb") & ";"
: objConn.Open
:
: 'Declare variables and set their values
: Dim adCmdText
: Dim strClass
: Dim lngLength
: Dim lngWeight
: Dim lngMainJib
: Dim lngSpinnaker
: Dim strAuthority
: adCmdText = 1
: strClass = "Mini Laser"
: lngLength = 3
: lngWeight = 45
: lngMainJib = 6
: lngSpinnaker = 0
: strAuthority = "www.laser.com"
:
: 'Create the command object and set the query to be executed
: Set objCmd = Server.CreateObject("ADODB.Command")
: Set objCmd.ActiveConnection = objConn
: objCmd.CommandText = "{call qparmInsertBoatClass ('" & CStr(strClass) & _
: "'," & CLng(lngLength) & "," & CLng(lngWeight) & _
: "," & CLng(lngMainJib) & "," & CLng(lngSpinnaker) & _
: ",'" & CStr(strAuthority) & "')}"
: objCmd.CommandType = adCmdText
: objCmd.Execute
:
: 'Close and dereference database objects
: objConn.Close
: Set objConn = Nothing
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


  Return to Index