Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Posts
    53

    Red face Unanswered: error:data type mismatch

    hai...everybody....
    my problem is, i want to do 2 process in one page...actually i copy this coding from my friend..but it cannot work on my page.it always give me error : data type mismatch.
    below are the coding:

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <%
    Dim aduan
    Dim id
    Dim pengguna
    Dim code
    Dim sbb
    Dim lok
    Dim blok
    Dim ting
    Dim bil
    Dim tarikh
    Dim arah
    Dim bhn
    Dim lapor
    Dim stat
    Dim upah
    Dim kosbhn
    Dim runding
    Dim jumkos
    Dim sq
    Dim db
    Dim sq2
    Dim sq3
    Dim rs
    aduan=request.form("textfield2")
    pengguna=request.form("textfield3")
    code=request.form("textfield4")
    sbb=request.form("textfield5")
    lok=request.form("textfield6")
    blok=request.form("textfield7")
    ting=request.form("textfield8")
    bil=request.form("textfield9")
    tarikh=request.form("textfield10")
    arah=request.form("textfield11")
    bhn=request.form("textfield12")
    lapor=request.form("textfield13")
    stat=request.form("textfield14")
    upah=request.form("textfield15")
    kosbhn=request.form("textfield16")
    runding=request.form("textfield17")
    jumkos=request.form("textfield18")


    set db = Server.CreateObject ("ADODB.Connection")
    db.Open "sambung"

    sq= "INSERT INTO tb_arkib(id_aduan, id_user, kod_kerosakan, sebab_kerosakan, lokasi, blok, tingkat, no_bilik,tarikhmasa, arahan, bhn_ganti,laporan,status_id, upah,kosbhn_ganti,perundingan, jumlah_kos) VALUES ('" & aduan & "', '" & pengguna & "', '" & code & "', '" & sbb & "', '" & lok & "', '" & blok & "', '" & ting & "', '" & bil & "', '" & tarikh & "', '" & arah & "', '" & bhn & "', '" & lapor & "', '" & stat & "', '" & upah & "', '" & kosbhn & "', '" & runding & "', '" & jumkos & "')"
    'sq="INSERT INTO tb_arkib FROM tb_aduan a WHERE id_aduan='" & id & "'"
    set rs = db.execute(sq)

    'sq="SELECT * FROM tb_aduan"
    'set rs=db.execute(sq)
    'do while NOT rs.EOF
    sq2= " DELETE * FROM tb_aduan WHERE id_aduan = '" & aduan & "' "
    set rs = db.execute(sq2)
    'rs.movenext
    'loop
    'rs.close
    db.close


    Response.Redirect ("timakasih.asp")
    %>

    </body>

    </html>

    the format of id_aduan is actually autonumber. i think the error is something to do with the id_aduan. can somebody help me.
    this is the last page before i can present it to my bos.....
    i really need help

  2. #2
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    First, I don't see a connection string anywhere, and "sambung" does not look like a valid one to me. Second, if id_aduan is an autonumber, then you can leave it out of your insert entirely. Third, of all those values you're inserting, make sure they match the expected value of the table. If you're attempting to insert an alphabetic character into a numeric column, you'll get a datatype mismatch error.
    That which does not kill me postpones the inevitable.

  3. #3
    Join Date
    Mar 2004
    Posts
    53

    insert ok...

    actually the insert command is ok.the probem now is the delete command. all the data can be insert but cannot be delete.there is a mismatch error and cannot execute the delete command

  4. #4
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    Oh, there's no * in the DELETE command.

    DELETE FROM tb_aduan WHERE id_aduan = '" & aduan & "'"

    And if id_aduan is a number, you don't need single quotes around it

    DELETE FROM tb_aduan WHERE id_aduan = " & aduan

    Keep in mind, this command deletes the entire row in the table, not values of the row. If you want to clear values of a row, you need to use an UPDATE command and set those values to empty (or NULL if the field is nullable).
    That which does not kill me postpones the inevitable.

Posting Permissions

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