Results 1 to 7 of 7

Thread: ADO SQL query

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2000
    Posts
    51

    Post

    I have problem with the following code. The MANUFACTOR was selected from the Manufactor_model field in SQL table, but when I run this, the code CAN'T find the record. Do I need to add someting to the line sqltemp="select * from HWtable where Manufactor_model = '"& MANUFACTOR &"'", since the Manufactor_model field type is nvarchar?

    Thanks....

    <%
    myDSN="DSN=INVENTORY;uid=xxx;pwd=xxx"
    set conntemp=server.createobject("adodb.connection")
    conntemp.open myDSN
    MANUFACTOR=Request.QueryStrin("MANUFACTORY")

    sqltemp="select * from HWtable where Manufactor_model = '"& MANUFACTOR &"'"

    set rstemp = conntemp.execute(sqltemp)

    PROCESSOR= rstemp("processor")
    RAM_INSTALLED= rstemp("RAM_INSTALL")
    RAM_MAX= rstemp("RAM_MAX")
    VIDEO_CARD= rstemp("VIDEO_CARD")
    VIDEO_MEM= rstemp("VIDEO_MEM")
    RESOLUTION= rstemp("RESOLUTION")

    rstemp.close
    set rstemp=nothing
    conntemp.close
    set conntemp=nothing
    %>

  2. #2
    Junior Member
    Join Date
    Feb 2000
    Posts
    19

    Post

    Try using Like operator instead of equal. Sometimes this makes a differnce.

  3. #3
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    What field in your DB is the INT type?

  4. #4

    Thread Starter
    Member
    Join Date
    Jan 2000
    Posts
    51

    Post

    Didn't work with like. I wonder if the field manufactor_model being a nvarchar have to with it.

  5. #5
    Junior Member
    Join Date
    Feb 2000
    Posts
    19

    Post

    Are you getting any syntax errors or is it just returning no records found.

    It appears as if you are not checking to see if MANUFACTOR has something in it. try putting in an if something like this:

    if Request.QueryStrin("MANUFACTORY") = "" Then
    MANUFACTOR="%"
    else
    MANUFACTOR=Request.QueryStrin("MANUFACTORY")
    end if

    This will check for empty strings and handle blank fields in the sql query. You will still have to use the like operator for this.

    If you have handled the empty string else where then sorry this probably won't help.

    hope this is helpful

    Marita_l

  6. #6
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    You are missing the G at the end of QueryStrin, maybe that'll do it....but your code looks right unless you are not receiving the value of the manufacturer....try using response.write at various points to determine if your script is working correctly

  7. #7

    Thread Starter
    Member
    Join Date
    Jan 2000
    Posts
    51

    Post

    There is a response with reponse.write, I have no problem if I used the field with INT type. Any other suggestions?

    Thanks...

Posting Permissions

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



Click Here to Expand Forum to Full Width