I am trying to pass an input parater to SQL Server. The parameter is a URL
querystring variable. I can't seem to get it to pass a variable, only a
literal value...
Help!
In the following example, the @archiveType parameter accepts the "all"
sample value. If I replace "all" with Request.QuerySt ring("archiveTy pe"),
it doesn't work. What am I doing wrong?
'SqlSelectComma nd1
'
Me.SqlSelectCom mand1.CommandTe xt = "[myProcedure]"
Me.SqlSelectCom mand1.CommandTy pe = System.Data.Com mandType.Stored Procedure
Me.SqlSelectCom mand1.Connectio n = Me.SqlConnectio n1
Me.SqlSelectCom mand1.Parameter s.Add(New
System.Data.Sql Client.SqlParam eter("@RETURN_V ALUE",
System.Data.Sql DbType.Int, 4, System.Data.Par ameterDirection .ReturnValue,
False, CType(0, Byte), CType(0, Byte), "",
System.Data.Dat aRowVersion.Cur rent, Nothing))
Me.SqlSelectCom mand1.Parameter s.Add(New
System.Data.Sql Client.SqlParam eter("@archiveT ype",
System.Data.Sql DbType.VarChar, 5, System.Data.Par ameterDirection .Input,
False, CType(0, Byte), CType(0, Byte), "",
System.Data.Dat aRowVersion.Cur rent, "all"))
---------------------------------
Here's the procedure:
CREATE PROCEDURE myProcedure
@archiveType varchar(5)
as
SELECT col1
FROM table1
WHERE col1 = @archiveType
--
_____
DC G
querystring variable. I can't seem to get it to pass a variable, only a
literal value...
Help!
In the following example, the @archiveType parameter accepts the "all"
sample value. If I replace "all" with Request.QuerySt ring("archiveTy pe"),
it doesn't work. What am I doing wrong?
'SqlSelectComma nd1
'
Me.SqlSelectCom mand1.CommandTe xt = "[myProcedure]"
Me.SqlSelectCom mand1.CommandTy pe = System.Data.Com mandType.Stored Procedure
Me.SqlSelectCom mand1.Connectio n = Me.SqlConnectio n1
Me.SqlSelectCom mand1.Parameter s.Add(New
System.Data.Sql Client.SqlParam eter("@RETURN_V ALUE",
System.Data.Sql DbType.Int, 4, System.Data.Par ameterDirection .ReturnValue,
False, CType(0, Byte), CType(0, Byte), "",
System.Data.Dat aRowVersion.Cur rent, Nothing))
Me.SqlSelectCom mand1.Parameter s.Add(New
System.Data.Sql Client.SqlParam eter("@archiveT ype",
System.Data.Sql DbType.VarChar, 5, System.Data.Par ameterDirection .Input,
False, CType(0, Byte), CType(0, Byte), "",
System.Data.Dat aRowVersion.Cur rent, "all"))
---------------------------------
Here's the procedure:
CREATE PROCEDURE myProcedure
@archiveType varchar(5)
as
SELECT col1
FROM table1
WHERE col1 = @archiveType
--
_____
DC G
Comment