SQL & Querystring Question (probably simple)

Results 1 to 7 of 7

Thread: SQL & Querystring Question (probably simple)

  1. #1
    kimberlyj Guest

    Default SQL & Querystring Question (probably simple)

    Hi Everyone!<BR>I am having weirdness today with an application and a querystring. Essentially the sub gets the value in the querystring and then runs a:<BR>"Select * from Table where ColumnName = &#039;" & querystringvalue & "&#039;" . <BR>This works fine if the querystring is all numeric (eg. 45602) but if the querystring value has letters in it (e.g. BLT768) the page gives me an error of:<BR><BR>Microsoft OLE DB Provider for SQL Server error &#039;80040e14&#039; <BR><BR>Invalid column name &#039;BLT768&#039;. <BR><BR>Any help is appreciated!<BR>Thanks!<BR>Kimberly<BR><BR><BR>

  2. #2
    prakash Guest

    Default Datatype mismatch

    Well what is the datatype in DB.<BR><BR>you mean :<BR>select * from Tablename where fieldName = &#039;" & xxx & "&#039;

  3. #3
    Join Date
    Dec 1969

    Default RE: SQL & Querystring Question (probably simple)

    run it in query analizer,see what it says:<BR>Select * from Table where ColumnName = &#039;BLT768&#039;<BR><BR>

  4. #4
    Jannet Guest

    Default RE: SQL & Querystring Question (probably simple)

    TRY....<BR><BR>"Select * from Table where ColumnName = " & "&#039;" & querystringvalue & "&#039;" <BR><BR>if this doesn&#039;t work check for the datatype in the DB. <BR>

  5. #5
    kimberlyj Guest

    Default RE: Datatype mismatch- its nvarchar

    Since it is nvarchar shouldn&#039;t it take letters too? All of my other pages work fine but all the querystring values are numeric except this one.<BR>My select statement (to clarify) needs to pull all the records where the fieldName value equals the querystring value. e.g.<BR>if it is an auction, select all bids where bidderID= queryStringValue. <BR>Any ideas on how to make it work?<BR>Thanks!<BR>Kimberly<BR>

  6. #6
    kimberlyj Guest

    Default Thank you Mike and Jannet!

    Hi Guys!<BR>I ran it through the query analyzer and it gave me the right results. I tried Jannet&#039;s code it worked!! Thank you so much! Don&#039;t you just love how one space can make the difference between a big fat error and the promised land? :)<BR>Kimberly

  7. #7
    prakash Guest

    Default RE: Datatype mismatch- its nvarchar

    run the query in Query Analyser....I think you will figure it out....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts