trying to pass Request.QueryString as input parameter

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • DC Gringo

    trying to pass Request.QueryString as input parameter

    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


  • Cor Ligthert

    #2
    Re: trying to pass Request.QuerySt ring as input parameter

    DC Gringo

    A lot of crossposting however the right newsgroup you just missed in my
    opinion.

    From the dotnet groups are the SQL guys the most in this newsgroup.

    Adonet
    news://msnews.microsoft.com/microsof...amework.adonet

    Web interface:


    When I see it right you are getting this as result from what you are doing
    (not really checking it complete)

    select col1 from table1 where col1 = 'all'

    I don't believe that this is what you want to archieve, however that you
    want
    select col1 from table1

    However I am not a real SQL one. (Better I hate it)

    Cor



    Comment

    Working...