Results 1 to 4 of 4

Thread: Data Mismatch

  1. #1
    Join Date
    Nov 2003
    Posts
    3

    Unanswered: Data Mismatch

    Hi I have created an access database which keeps a record of renting out laptops to people. I use asp to connect to my web pages where the details of name , address etc can be typed in. I have a lend button which allows one to type in the details and then updtae the details to the database. I also have a button that indicates that the laptop is rented out and all I want to do is when one clicks on that button it shows the details of whom the laptop is rented out to. It sounds so simple and I have it almost complete I jsu cant get it to pull up the details. I have tried response. write. Maybe someone can help, please. Thank you.

    Here is my page of code. The problem is the sql statement it says there is a data mismatch but I cant see it.

    <% @LANGUAGE="VBSCRIPT"%>

    <%
    Dim dbconn
    Dim LaptopID, Lendee, Location, Phone, ltID , rs1, sql, In_Out

    ' Create and establish data connection
    Set dbconn = Server.CreateObject("ADODB.Connection")
    dbconn.ConnectionTimeout = 15
    dbconn.CommandTimeout = 30

    'Use this line to use Access
    dbconn.Open "DBQ= "& Server.MapPath("laptops.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};DriverId=25;MaxBufferSize=8192;Threads=20 ;"
    %>

    <%
    ' Create recordset and retrieve values using the open connection
    Set rs1 = Server.CreateObject("ADODB.Recordset")
    ' Opening record set with a forward-only cursor (the 0) and in read-only mode (the 1)
    rs1.Open "SELECT Lendee, Location, phone, In_Out FROM LaptopDetails Where LaptopID='" & ltID & "'", dbconn
    %>

    <%
    if request.querystring("LaptopID")<>"" then
    ltID=request.querystring("LaptopID")
    end if

    if request.querystring("LaptopID")<>"" then ltID=request.querystring("LaptopID")end if
    if Request.querystring("Lendee") <> "" then Lendee=request.querystring("Lendee")end if
    if Request.querystring("Location") <> "" then Location=Request.querystring("Location")end if
    if Request.querystring("Phone") <> "" then Phone=Request.querystring("Phone") end if
    %>

    <html>
    <body>

    <h2>Lend Details</h2>


    <p><font color="#FF0000">LaptopID: </font><%Response.write (LaptopID)%>
    <p><font color="#FF0000">Name: </font><%Response.write (Lendee)%>
    <p><font color="#FF0000">Address: </font><%Response.write (Location)%>
    <p><font color="#FF0000">Telephone: </font><%Response.write (Phone)%>




    <% dbconn.close %>

  2. #2
    Join Date
    Oct 2002
    Location
    Argentina
    Posts
    72

    Re: Data Mismatch

    i Think you must write the rs values:

    Something like this:

    Response.write (rs1("Location"))

    Hope this helps.






    Originally posted by rebecca2003
    Hi I have created an access database which keeps a record of renting out laptops to people. I use asp to connect to my web pages where the details of name , address etc can be typed in. I have a lend button which allows one to type in the details and then updtae the details to the database. I also have a button that indicates that the laptop is rented out and all I want to do is when one clicks on that button it shows the details of whom the laptop is rented out to. It sounds so simple and I have it almost complete I jsu cant get it to pull up the details. I have tried response. write. Maybe someone can help, please. Thank you.

    Here is my page of code. The problem is the sql statement it says there is a data mismatch but I cant see it.

    <% @LANGUAGE="VBSCRIPT"%>

    <%
    Dim dbconn
    Dim LaptopID, Lendee, Location, Phone, ltID , rs1, sql, In_Out

    ' Create and establish data connection
    Set dbconn = Server.CreateObject("ADODB.Connection")
    dbconn.ConnectionTimeout = 15
    dbconn.CommandTimeout = 30

    'Use this line to use Access
    dbconn.Open "DBQ= "& Server.MapPath("laptops.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};DriverId=25;MaxBufferSize=8192;Threads=20 ;"
    %>

    <%
    ' Create recordset and retrieve values using the open connection
    Set rs1 = Server.CreateObject("ADODB.Recordset")
    ' Opening record set with a forward-only cursor (the 0) and in read-only mode (the 1)
    rs1.Open "SELECT Lendee, Location, phone, In_Out FROM LaptopDetails Where LaptopID='" & ltID & "'", dbconn
    %>

    <%
    if request.querystring("LaptopID")<>"" then
    ltID=request.querystring("LaptopID")
    end if

    if request.querystring("LaptopID")<>"" then ltID=request.querystring("LaptopID")end if
    if Request.querystring("Lendee") <> "" then Lendee=request.querystring("Lendee")end if
    if Request.querystring("Location") <> "" then Location=Request.querystring("Location")end if
    if Request.querystring("Phone") <> "" then Phone=Request.querystring("Phone") end if
    %>

    <html>
    <body>

    <h2>Lend Details</h2>


    <p><font color="#FF0000">LaptopID: </font><%Response.write (LaptopID)%>
    <p><font color="#FF0000">Name: </font><%Response.write (Lendee)%>
    <p><font color="#FF0000">Address: </font><%Response.write (Location)%>
    <p><font color="#FF0000">Telephone: </font><%Response.write (Phone)%>




    <% dbconn.close %>

  3. #3
    Join Date
    Nov 2003
    Posts
    3
    hi thanks for your help but it still says data mismatch, it has something to do with the ltID and I dont know what. This is the way the code stands at the minute.

    rs1.Open "SELECT Lendee, Location, phone, In_Out FROM LaptopDetails where LaptopID ='" & ltID & "'", dbconn


    but if I write this

    rs1.Open "SELECT Lendee, Location, phone, In_Out FROM LaptopDetails where LaptopID =10"

    It brings up the information about laptop 10.
    Any Ideas?

    Thanks

  4. #4
    Join Date
    Nov 2003
    Posts
    3
    hi there its ok I got the problem sorted I needed to put my if request.querystrings above my select statement.

    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
  •