|
 |
asp_databases thread: Can ASP use a sql statement against a database view which need a parameter?
Message #1 by "spring zhang" <spring.z@c...> on Fri, 20 Apr 2001 01:48:11
|
|
I have create a view name view1 which need a parameter to execute. then I
use a sql statement to do a query against the view.
following is my code:
strSQL = "Select * from view1 where condition;"
objCm.CommandText =strSQL
objCm.CommandType = 4
GroupID = Request("GroupID")
Set Prm = objCm.CreateParameter
("prm",adChar,adParamInput,255,GroupID)
objCm.Parameters.append Prm
set objRS = objCm.execute
Error message:
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access Driver] Expected query name after
EXECUTE.
/chinae-com/pchn/rep/updateoppcountinfo_group.asp, line 73
And if I change the objCm.CommandType to 1, the another error will occurs
says that:
Microsoft OLE DB Provider for ODBC Drivers error '80040e10'
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
How to solve it?
TIA.
Message #2 by "Charles Feduke" <webmaster@r...> on Thu, 19 Apr 2001 22:57:41 -0400
|
|
> set objRS = objCm.execute
Hrm. Instead of setting the CommandText and CommandType to strSQL,
try...
Private Const adCmdText = &H0001
Set objRS = objCm.Execute strSQL, , adCmdText
I don't know what command type 4 is, but here's the published constants:
' command type
Public Const adCmdUnknown = &H0008
Public Const adCmdText = &H0001
Public Const adCmdTable = &H0002
Public Const adCmdStoredProc = &H0004
Public Const adCmdFile = &H0100
Public Const adCmdTableDirect = &H0200
Hope that helps.
- Chuck
----- Original Message -----
From: "spring zhang" <spring.z@c...>
To: "ASP Databases" <asp_databases@p...>
Sent: Friday, April 20, 2001 1:48 AM
Subject: [asp_databases] Can ASP use a sql statement against a database view
which need a parameter?
> I have create a view name view1 which need a parameter to execute. then I
> use a sql statement to do a query against the view.
>
> following is my code:
>
> strSQL = "Select * from view1 where condition;"
>
> objCm.CommandText =strSQL
> objCm.CommandType = 4
>
> GroupID = Request("GroupID")
> Set Prm = objCm.CreateParameter
> ("prm",adChar,adParamInput,255,GroupID)
> objCm.Parameters.append Prm
>
> set objRS = objCm.execute
>
> Error message:
> Microsoft OLE DB Provider for ODBC Drivers error '80004005'
> [Microsoft][ODBC Microsoft Access Driver] Expected query name after
> EXECUTE.
> /chinae-com/pchn/rep/updateoppcountinfo_group.asp, line 73
>
>
> And if I change the objCm.CommandType to 1, the another error will occurs
> says that:
> Microsoft OLE DB Provider for ODBC Drivers error '80040e10'
> [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
>
> How to solve it?
>
> TIA.
|
|
 |