Problem with database in asp

Results 1 to 4 of 4

Thread: Problem with database in asp

  1. #1
    Mampuys g Guest

    Default Problem with database in asp

    I have a question.<BR><BR>I have a database with 2 fields,one textfield en one numeric field(double precision).When I enter a name in a inputfield in the searchform(ok1.htm) and I post it to (ok1.asp)for search in the textfield from the database,I get the correct information out of the database.But when I enter a number in the same inputfield in the searchform(ok.htm) and I post it to(ok1.asp)for search in the numeric field from the database,I get a datatype mismatch error.<BR><BR>I have personal web server 4.0<BR><BR> <BR><BR>&#060;%@ Language=VBScript %&#062;<BR><BR> <BR><BR>&#060;%Response.Buffer=true%&#062;<BR><BR> &#060;%<BR><BR>Dim sSQL,myconn,rs<BR><BR> <BR><BR>Set myconn = Server.CreateObject("ADODB.Connection")<BR><BR>Mdb FilePath = server.MapPath("db2.mdb")<BR><BR> <BR><BR>myconn.Open "DRIVER={MICROSOFT ACCESS DRIVER (*.mdb)};DBQ=" & MdbFilePath & ";" <BR><BR>&#039DSN less connection<BR><BR>SQL_query = "Select * From ACTO where appmer = &#039" & _ <BR><BR>Request.Form("aannmr") & "&#039" <BR><BR>Set RS=Myconn.Execute(SQL_query)<BR><BR>%&#062;<BR><BR >appmer is the textfield in the table I have then no error and correct information.<BR><BR>Aannmr is the numeric field (double precision) in the table.<BR><BR>When I replace appmer by aannmr in the query and do a search I have datatype mismatch error.<BR><BR>Db2.mdb contains the database table.<BR><BR> Can you help me to salve this problem if possible with an example.<BR><BR> <BR><BR> <BR>

  2. #2
    Steve Cimino Guest

    Default RE: Problem with database in asp

    SQL_query = "Select * From ACTO where appmer = " & _ <BR><BR>CDbl(Request.Form("aannmr"))<BR><BR>No single quotes for a number.

  3. #3
    Join Date
    Dec 1969

    Default RE: Problem with database in asp

    You can&#039t have quotes around your search string if it&#039s a numeric field. Change your SQL to read:<BR><BR>SQL_query = "Select * From ACTO where aannmr = " & Request.Form("aannmr")

  4. #4
    Join Date
    Dec 1969
    Los Angeles, CA

    Default Problem with QUERY in asp

    If it is a numeric filed you SHOULD NOT HAVE the &#039<BR><BR>the &#039 will only be used for text, char, date...fields<BR><BR>int and numeric fields will SHOULD NOT have the &#039

Posting Permissions

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