Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

ASP&SQL little help?

Options
  • 15-08-2002 5:36pm
    #1
    Closed Accounts Posts: 1,719 ✭✭✭


    ok i'm trying to insert the contents of a form(3 fields called FullName, Email and Descript) into a table called Test. i have the connection setup,it's just that i get a http500(Expected end of statement)
    the string is
    "INSERT INTO Temp (FullName, Email, descript) VALUES ('Request.Form("Name")', 'Request.Form("Email")', 'Request.Form("Descript")' "

    any idea's where i've gone wrong?i've been staring at it too long now and i wont see where i've gone wrong.


Comments

  • Registered Users Posts: 11,987 ✭✭✭✭zAbbo


    could you post the full <form>????</form> contents up as code please, there doesn`t seem anything out of hand there.

    But maybe with the full code, might shed some light on the prob.


  • Closed Accounts Posts: 1,719 ✭✭✭Ruaidhri


    note:removed some of the connection string.cause i'm paranoid ;) but the connection string DOES work.trued it with simple select commands
    <HTML>
    <%@ Language=VBScript %>
    <% Response.Buffer=true %>
    <%Request.QueryString("id")%>
    <!-- #include file="Adovbs.inc"-->
    <%


    If Request.Form("posted") = 1 Then 'form posted

    Dim oCmd
    Dim adoRS

    Set oCmd = server.CreateObject("ADODB.Command")
    Set adoRs = server.CreateObject("ADODB.Recordset")

    oCmd.ActiveConnection = "Driver={SQL Server};server=ruairi;Uid=;Pwd=;Database=IssueTracker"
    oCmd.CommandText = "INSERT INTO Temp (FullName, Email, descript) VALUES ('Request.Form("Name")', 'Request.Form("Email")', 'Request.Form("Descript")'"

    Set adoRS = oCmd.Execute
    Response.Write "<br> </br>Thankyou for signing up. Your information has been added to our database!<br> </br>"
    oCmd.ActiveConnection = Nothing

    Else 'display the form %>



    <form action="forminput.asp" method="post" id=form1 name=form1>
    <INPUT style="WIDTH: 156px; HEIGHT: 22px"
    size=19 name=Name>
    <input name="Email">
    <INPUT name="Descript" style="WIDTH: 435px; FONT-FAMILY: fantasy; HEIGHT: 119px" size=56>
    <INPUT id=submit1 style="BORDER-LEFT-COLOR: #5442a8; BORDER-BOTTOM-COLOR: #5442a8; BORDER-TOP-COLOR: #5442a8; BACKGROUND-COLOR: whitesmoke; BORDER-RIGHT-COLOR: #5442a8" type=submit value=Submit name=submit1>
    <input type="hidden" name="Posted" value="1">
    </FORM>
    <% End If %>



  • Registered Users Posts: 771 ✭✭✭whiteshadow


    hi instead of the

    oCmd.CommandText = "INSERT INTO Temp (FullName, Email, descript) VALUES ('Request.Form("Name")', 'Request.Form("Email")', 'Request.Form("Descript")'"

    try asigning to variables first

    tempname = request.form("Name")
    tempemail = request.form("email")
    tempdesc = request.form("descript")

    then after you open the connection

    "INSERT INTO Temp (FullName, Email, descript) VALUES (' " & tempname & " ', ' " & tempemail & " ', ' " & tempname & " ')


  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    My ASP is rusty, but shouldnt that be something like :
    "INSERT INTO Temp (FullName, Email, descript) VALUES '"  & Request.Form("Name") & "', '" & Request.Form("Email")
    & "', '" & Request.Form("Descript") "' "
    

    In other words...take the Request.Form calls outside the string quotes, otherwise theyre only literal string content, and not instructions?

    Incidentally, if you use Ruadhri's variable suggestion, you'll need to do this anyway.

    jc


  • Closed Accounts Posts: 5,564 ✭✭✭Typedef


    oCmd.CommandText = "INSERT INTO Temp (FullName, Email, descript) VALUES (('Request.Form("Name")', 'Request.Form("Email")', 'Request.Form("Descript"))'"
    

    else
    Dim gcc
    Dim gnu
    Dim udma100
    
    set gcc=Request.Form("Name")
    set gnu=Request.Form("Email")
    set udma100=Request.Form("Descript")
    
    
    set oCmd.CommandText = "INSERT INTO Temp (FullName, Email, descript) VALUES (gcc,gnu,udma100)"
    

    You will appreciate this is just a guess ok?


  • Advertisement
Advertisement