|
 |
asp_databases thread: Re: Getting values for a single row from Command parameters
Message #1 by "Drew, Ron" <RDrew@B...> on Wed, 10 Jul 2002 10:29:58 -0400
|
|
I use the ? For the parameter and it works.
Dim sName
sName =3D Request.Form.Item("theformname")
strSQL =3D "SELECT Name FROM tablea WHERE Name =3D ?"
objCommand.CommandText =3D strSQL
objCommand.Parameters.Append objCommand.CreateParameter("Name",200,
,30)
objCommand("Name") =3D sName
objCommand.Execute
-----Original Message-----
From: Marcos Vale [mailto:mnvale@h...]
Sent: Wednesday, July 10, 2002 9:58 AM
To: ASP Databases
Subject: [asp_databases] Re: Getting values for a single row from
Command parameters
Ok, this code works but how to get the parameter "Body" ?
The two line below don't work.
(1) Dim sBody As String
(2) sBody =3D oCmd.Parameters ("Body").Value
> I am trying to retrieve a single row of data from using the command
> parameters with the direction adParamOutput,
> This code is not throwing any errors but I don't get the data.
> I thought is was possible to get the data for a single row without
using
a
> recordset, am I wrong?
>
> <%
>
> iNewsID =3D Request("NewsID")
> if iNewsID =3D "" then
> iNewsID =3D 0 ' no error - send something
> end if
>
> set oConn =3D server.CreateObject ("ADODB.connection")
> set oCmd =3D server.CreateObject ("ADODB.command")
> oConn.Open (Application("TestString"))
>
> sSql =3D "news_item"
>
> with oCmd
> .ActiveConnection =3D oConn
> .CommandText =3D sSql
> .CommandType =3D adCmdStoredProc
> .Parameters.Append oCmd.CreateParameter ("NewsID", adInteger,
> adParamInput, 4)
> .Parameters("NewsID").Value =3D iNewsID
> set oParam =3D .CreateParameter ("Headline", adVarChar,
> adParamOutput, 50)
> .Parameters.Append oParam
> set oParam =3D .CreateParameter ("Brief", adVarChar,
adParamOutput,
> 4000)
> .Parameters.Append oParam
> set oParam =3D .CreateParameter ("PublishDate", adDate,
> adParamOutput, 8)
> .Parameters.Append oParam
> set oParam =3D .CreateParameter ("Category", adInteger,
> adParamOutput, 4)
> .Parameters.Append oParam
> set oParam =3D .CreateParameter ("Body", adLongVarChar,
> adParamOutput, 32000)
> .Parameters.Append oParam
> .Execute
> end with
>
> sHeadline =3D oCmd.Parameters("Headline").Value
> sBrief =3D oCmd.Parameters ("Brief").Value
> dPublishDate =3D oCmd.Parameters ("PublishDate").Value
>
> set oCmd =3D nothing
> oConn.Close
> set oConn =3D nothing
>
>
> with response
> .Write "headline: " & sHeadline & "<BR>"
> .Write "brief: " & sBrief & "<BR>"
> .Write "pubdate: " & dPublishDate & "<BR>"
> end with
> %>
Message #2 by "Marcos Vale" <mnvale@h...> on Wed, 10 Jul 2002 13:58:24
|
|
Ok, this code works but how to get the parameter "Body" ?
The two line below don't work.
(1) Dim sBody As String
(2) sBody = oCmd.Parameters ("Body").Value
> I am trying to retrieve a single row of data from using the command
> parameters with the direction adParamOutput,
> This code is not throwing any errors but I don't get the data.
> I thought is was possible to get the data for a single row without using
a
> recordset, am I wrong?
>
> <%
>
> iNewsID = Request("NewsID")
> if iNewsID = "" then
> iNewsID = 0 ' no error - send something
> end if
>
> set oConn = server.CreateObject ("ADODB.connection")
> set oCmd = server.CreateObject ("ADODB.command")
> oConn.Open (Application("TestString"))
>
> sSql = "news_item"
>
> with oCmd
> .ActiveConnection = oConn
> .CommandText = sSql
> .CommandType = adCmdStoredProc
> .Parameters.Append oCmd.CreateParameter ("NewsID", adInteger,
> adParamInput, 4)
> .Parameters("NewsID").Value = iNewsID
> set oParam = .CreateParameter ("Headline", adVarChar,
> adParamOutput, 50)
> .Parameters.Append oParam
> set oParam = .CreateParameter ("Brief", adVarChar, adParamOutput,
> 4000)
> .Parameters.Append oParam
> set oParam = .CreateParameter ("PublishDate", adDate,
> adParamOutput, 8)
> .Parameters.Append oParam
> set oParam = .CreateParameter ("Category", adInteger,
> adParamOutput, 4)
> .Parameters.Append oParam
> set oParam = .CreateParameter ("Body", adLongVarChar,
> adParamOutput, 32000)
> .Parameters.Append oParam
> .Execute
> end with
>
> sHeadline = oCmd.Parameters("Headline").Value
> sBrief = oCmd.Parameters ("Brief").Value
> dPublishDate = oCmd.Parameters ("PublishDate").Value
>
> set oCmd = nothing
> oConn.Close
> set oConn = nothing
>
>
> with response
> .Write "headline: " & sHeadline & "<BR>"
> .Write "brief: " & sBrief & "<BR>"
> .Write "pubdate: " & dPublishDate & "<BR>"
> end with
> %>
|
|
 |