#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2011
    Posts
    4
    Rep Power
    0

    Question Asp vbscript DB question.


    Hi all,

    I have this code:

    Dim objConn, objRS, strQ, a, b, stsql, stuser, stpass, stadd, stpost, stfull

    strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
    Server.MapPath("\test\example.mdb")
    Set objconnection = Server.CreateObject("ADODB.Connection")
    objconnection.Open strConnection

    stuser = request.form("username")
    stpass = request.form("password")
    stfull = request.form("fullname")
    stadd = request.form("add")
    stpost = request.form("postcode")
    strSQL = "INSERT INTO members(username, pass, fullname) VALUES('" & stuser & "','" & stpass & "','" & stfull & "')"
    objConnection.Execute strSQL



    which works fine apart from its not adding the stfull part to the database. any ideas anybody?
    If I take out the , fullname part it works fine.
    the fullname is a field in the db.

    the form code is:

    <tr align="center">
    <td width="248" height="17" bgcolor="#C0C0C0" align="right"><font color="#000000"><small>Add
    Your Full Name:</small></font></td>
    <td height="17" width="123" bgcolor="#C0C0C0" align="left"><input type="text"
    name="fullname" size="50" tabindex="3" maxlength="8"></td>
    <td width="47" height="17" bgcolor="#C0C0C0" align="center"><a
    href="javascript:alert('The password must be between 4 and 8 characters long.')"><small><small>Help</small></small></a></td>
    </tr>



    thanks

    Martin
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2011
    Posts
    4
    Rep Power
    0

    ?????????


    I did a response.write and got this:

    INSERT INTO members(username, pass, add) VALUES('uytr','67456546','546')

    SQL looks ok to me.
    Can anybody shed any light on please as its driving me nuts

    thanks

    Martin
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2007
    Location
    Charlotte
    Posts
    412
    Rep Power
    144
    Originally Posted by swarv
    I did a response.write and got this:

    INSERT INTO members(username, pass, add) VALUES('uytr','67456546','546')

    SQL looks ok to me.
    Can anybody shed any light on please as its driving me nuts

    thanks

    Martin
    Copy/paste that into a SQL window and run it.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2011
    Posts
    4
    Rep Power
    0

    Question works


    Hi,

    works fine in access in sql window.

    any ideas on why it doesn't work in asp?

    thanks
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2007
    Location
    Charlotte
    Posts
    412
    Rep Power
    144
    Originally Posted by swarv
    Hi,

    works fine in access in sql window.

    any ideas on why it doesn't work in asp?

    thanks
    Somethings wrong. In your code sample, you have this:
    Code:
    strSQL = "INSERT INTO members(username, pass, fullname) VALUES('" & stuser & "','" & stpass & "','" & stfull & "')"
    objConnection.Execute strSQL
    Yet in your response.write you say you're getting this:

    Code:
    INSERT INTO members(username, pass, add) VALUES('uytr','67456546','546')
    How is that possible, that "fullname" is now "add" (the parts I bolded) ?

    The other thing you could do is some error trapping, to see if an error is being generated. Do a Google for:
    Code:
    classic asp error handling
    I found this:
    http://stackoverflow.com/questions/472558/is-try-catch-like-error-handling-possible-in-asp-classic
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2011
    Posts
    4
    Rep Power
    0

    hi


    Hi,

    that must have been a typo, i probably was trying different fields before i did the reponse.write.

    I'll have a look at error trapping now. It is a strange one.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2011
    Posts
    2
    Rep Power
    0
    Could you post your table structure?
    In the past I've had random intermittent issues with Memo fields in the past and it might be something there.

IMN logo majestic logo threadwatch logo seochat tools logo