Results 1 to 14 of 14

Thread: Empty string

  1. #1
    Join Date
    Apr 2003
    Posts
    7

    Unanswered: Empty string

    Hello there,

    Can some one tell why the string empty and get this error message?
    CompRecID =
    Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
    [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'CompRecID ='.
    /asp/info_form_handler.asp, line 18

    This is my code:
    <%
    Dim iRecId
    iRecId = Request.Form("CompRecID")

    Dim strTo, strQuery
    Dim objRS, objConn

    Set objConn = Server.CreateObject("ADODB.Connection")
    objConn.ConnectionString="DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.Mappath("\data\comp.mdb")
    objConn.Open

    response.write ("CompRecID = " & iRecId)

    Set objRS = Server.CreateObject("ADODB.Recordset")
    strQuery = "SELECT EmailInformation FROM Company Where CompRecID = " & iRecId

    objRS.Open strQuery, objConn

    strTo = objRS("EmailInformation")

    Set mailer = Server.CreateObject("SoftArtisans.SMTPMail")

    mailer.RemoteHost = "mail.company.com"

    If Request.form("Email_sender")<>"" Then
    mailer.FromAddress = Request.form("Email_sender")
    End if

    mailer.AddRecipient strTo

    mailer.Subject = "Request information"

    mailer.BodyText = "First Name: "& request.form("Firstname") & vbcrlf & "Middle Initial: "& request.form("Middleinitial") bla......

    If mailer.SendMail then
    Response.Write "<P> Mail sent."
    Else
    Response.Write "<p>Mail failure."
    End If

    Response.write "<br> " & mailer.response

    objRS.Close
    Set objRS = Nothing

    objConn.Close
    Set objConn = Nothing

    Set mailer = Nothing
    %>

  2. #2
    Join Date
    Apr 2003
    Location
    Connecticut
    Posts
    17

    Re: Empty string

    Hey,

    Make sure CompRecID is a valid field in your table and also use " ' " around your value since you are searching for and ID

    "SELECT EmailInformation FROM Company Where CompRecID = '" & iRecId & "' "


    Originally posted by Raven
    Hello there,

    Can some one tell why the string empty and get this error message?
    CompRecID =
    Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
    [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'CompRecID ='.
    /asp/info_form_handler.asp, line 18

    This is my code:
    <%
    Dim iRecId
    iRecId = Request.Form("CompRecID")

    Dim strTo, strQuery
    Dim objRS, objConn

    Set objConn = Server.CreateObject("ADODB.Connection")
    objConn.ConnectionString="DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.Mappath("\data\comp.mdb")
    objConn.Open

    response.write ("CompRecID = " & iRecId)

    Set objRS = Server.CreateObject("ADODB.Recordset")
    strQuery = "SELECT EmailInformation FROM Company Where CompRecID = " & iRecId

    objRS.Open strQuery, objConn

    strTo = objRS("EmailInformation")

    Set mailer = Server.CreateObject("SoftArtisans.SMTPMail")

    mailer.RemoteHost = "mail.company.com"

    If Request.form("Email_sender")<>"" Then
    mailer.FromAddress = Request.form("Email_sender")
    End if

    mailer.AddRecipient strTo

    mailer.Subject = "Request information"

    mailer.BodyText = "First Name: "& request.form("Firstname") & vbcrlf & "Middle Initial: "& request.form("Middleinitial") bla......

    If mailer.SendMail then
    Response.Write "<P> Mail sent."
    Else
    Response.Write "<p>Mail failure."
    End If

    Response.write "<br> " & mailer.response

    objRS.Close
    Set objRS = Nothing

    objConn.Close
    Set objConn = Nothing

    Set mailer = Nothing
    %>

  3. #3
    Join Date
    Apr 2003
    Posts
    7
    I get now this error message

    Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
    [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
    /asp/info_form_handler.asp, line 18

    and the CompRecID is still empty

    CompRecID =

  4. #4
    Join Date
    Apr 2003
    Location
    Connecticut
    Posts
    17
    Post your code with the change made.

    Originally posted by Raven
    I get now this error message

    Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
    [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
    /asp/info_form_handler.asp, line 18

    and the CompRecID is still empty

    CompRecID =

  5. #5
    Join Date
    Apr 2003
    Posts
    7
    <%
    Dim iRecId
    iRecId = Request.Form("CompRecID")

    Dim strTo, strQuery
    Dim objRS, objConn

    Set objConn = Server.CreateObject("ADODB.Connection")
    objConn.ConnectionString="DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.Mappath("\data\comp.mdb")
    objConn.Open

    response.write ("CompRecID = " & iRecId)

    Set objRS = Server.CreateObject("ADODB.Recordset")
    strQuery = "SELECT EmailInformation FROM Company Where CompRecID = '" & iRecId & "' "

    objRS.Open strQuery, objConn

    strTo = objRS("EmailInformation")

    Set mailer = Server.CreateObject("SoftArtisans.SMTPMail")

    mailer.RemoteHost = "mail.company.com"

    If Request.form("Email_sender")<>"" Then
    mailer.FromAddress = Request.form("Email_sender")
    End if

    mailer.AddRecipient strTo

    mailer.Subject = "Request information"

    mailer.BodyText = "First Name: "& request.form("Firstname") & vbcrlf & "Middle Initial: "& request.form("Middleinitial") bla......

    If mailer.SendMail then
    Response.Write "<P> Mail sent."
    Else
    Response.Write "<p>Mail failure."
    End If

    Response.write "<br> " & mailer.response

    objRS.Close
    Set objRS = Nothing

    objConn.Close
    Set objConn = Nothing

    Set mailer = Nothing
    %>

    Originally posted by bciarcia
    Post your code with the change made.

  6. #6
    Join Date
    Apr 2003
    Location
    Connecticut
    Posts
    17
    That code looks fine..

    1. Make sure the field in the form (CompRecID) is spelled correctly.

    2. instead of the Response.write ("CompRecID = " & iRecId), use
    MSGBOX("CompRecID = " & iRecID) just better debugging practice.

    3. What method are you submitting the form (Post,Get)

    4. If you are posting, you may want to try using Request.Querystring as the form fields get passed via a querystring. you can also use just plain Request("value").

  7. #7
    Join Date
    Apr 2003
    Posts
    7
    I tried a few things, for the moment i lost track.
    If i tried this first:
    strQuery = "SELECT EmailInformation FROM Company"
    It's getting the first email address from the database and when i try this:
    strQuery = "SELECT EmailInformation FROM Company Where CompRecID = '" & iRecId & "' "
    it's giving me errors.
    By the way i'm using the post method.


    Originally posted by bciarcia
    That code looks fine..

    1. Make sure the field in the form (CompRecID) is spelled correctly.

    2. instead of the Response.write ("CompRecID = " & iRecId), use
    MSGBOX("CompRecID = " & iRecID) just better debugging practice.

    3. What method are you submitting the form (Post,Get)

    4. If you are posting, you may want to try using Request.Querystring as the form fields get passed via a querystring. you can also use just plain Request("value").

  8. #8
    Join Date
    Apr 2003
    Location
    Connecticut
    Posts
    17
    what datatype is CompRecID in the database?

    also, try saying this;

    iRecId = Request.QueryString("CompRecID")


    Make sure the form variable you are passing from the form is spelled exactly the same way that you are spelling it on the calling page.

    Originally posted by Raven
    I tried a few things, for the moment i lost track.
    If i tried this first:
    strQuery = "SELECT EmailInformation FROM Company"
    It's getting the first email address from the database and when i try this:
    strQuery = "SELECT EmailInformation FROM Company Where CompRecID = '" & iRecId & "' "
    it's giving me errors.
    By the way i'm using the post method.

  9. #9
    Join Date
    Apr 2003
    Posts
    7
    CompRecID is autonumbering (long integer)

    These are the form input types:
    <FORM METHOD="Post" ACTION="../asp/info_form_handler.asp" name="General_Information">
    <input type="hidden" name="CompRecID" value="<%=CompRecID%>">
    <input type="hidden" name="Firstname" value="<%=Firstname%>">
    <input type="hidden" name="Middleinitial" value="<%=Middleinitial%>">
    <input type="hidden" name="Lastname" value="<%=Lastname%>">
    <input type="hidden" name="Title" value="<%=Title%>">
    <input type="hidden" name="Position" value="<%=Position%>">
    <input type="hidden" name="Phone1" value="<%=Phone1%>">
    <input type="hidden" name="Fax1" value="<%=Fax1%>">
    <input type="hidden" name="Email_sender" value="<%=Email_sender%>">
    <input type="hidden" name="Question" value="<%=Question%>">
    <input type="hidden" name="Institute" value="<%=Institute%>">
    <input type="hidden" name="Address" value="<%=Address%>">
    <input type="hidden" name="ZIPcode1" value="<%=ZIPcode1%>">
    <input type="hidden" name="City" value="<%=City%>">
    <input type="hidden" name="State" value="<%=State%>">
    <input type="hidden" name="POBox" value="<%=POBox%>">
    <input type="hidden" name="ZIPcode2" value="<%=ZIPcode2%>">
    <input type="hidden" name="Country" value="<%=Country%>">
    <input type="hidden" name="Phone2" value="<%=Phone2%>">
    <input type="hidden" name="Fax2" value="<%=Fax2%>">
    <input type="hidden" name="Email2" value="<%=Email2%>">
    <input type="hidden" name="URL" value="<%=URL%>">
    <INPUT TYPE=Submit NAME="Submit" value="Submit this information">
    </FORM>

    Originally posted by bciarcia
    what datatype is CompRecID in the database?

    also, try saying this;

    iRecId = Request.QueryString("CompRecID")


    Make sure the form variable you are passing from the form is spelled exactly the same way that you are spelling it on the calling page.

  10. #10
    Join Date
    Apr 2003
    Location
    Connecticut
    Posts
    17
    OK.. this may seem like a strange question, but have you tried making the field a plain text field to verify there is actually a value before you submit the form??


    Originally posted by Raven
    CompRecID is autonumbering (long integer)

    These are the form input types:
    <FORM METHOD="Post" ACTION="../asp/info_form_handler.asp" name="General_Information">
    <input type="hidden" name="CompRecID" value="<%=CompRecID%>">
    <input type="hidden" name="Firstname" value="<%=Firstname%>">
    <input type="hidden" name="Middleinitial" value="<%=Middleinitial%>">
    <input type="hidden" name="Lastname" value="<%=Lastname%>">
    <input type="hidden" name="Title" value="<%=Title%>">
    <input type="hidden" name="Position" value="<%=Position%>">
    <input type="hidden" name="Phone1" value="<%=Phone1%>">
    <input type="hidden" name="Fax1" value="<%=Fax1%>">
    <input type="hidden" name="Email_sender" value="<%=Email_sender%>">
    <input type="hidden" name="Question" value="<%=Question%>">
    <input type="hidden" name="Institute" value="<%=Institute%>">
    <input type="hidden" name="Address" value="<%=Address%>">
    <input type="hidden" name="ZIPcode1" value="<%=ZIPcode1%>">
    <input type="hidden" name="City" value="<%=City%>">
    <input type="hidden" name="State" value="<%=State%>">
    <input type="hidden" name="POBox" value="<%=POBox%>">
    <input type="hidden" name="ZIPcode2" value="<%=ZIPcode2%>">
    <input type="hidden" name="Country" value="<%=Country%>">
    <input type="hidden" name="Phone2" value="<%=Phone2%>">
    <input type="hidden" name="Fax2" value="<%=Fax2%>">
    <input type="hidden" name="Email2" value="<%=Email2%>">
    <input type="hidden" name="URL" value="<%=URL%>">
    <INPUT TYPE=Submit NAME="Submit" value="Submit this information">
    </FORM>

  11. #11
    Join Date
    Apr 2003
    Posts
    7
    Yes, did that allso

  12. #12
    Join Date
    Feb 2002
    Location
    San Francisco, CA
    Posts
    441
    try setting iRecID manually; this will allow you to narrow the problem down to this script; or the data being passed in. For example; replacing the line "...iRecID=request....." with
    Code:
    iRecId = 2

  13. #13
    Join Date
    Apr 2003
    Posts
    7
    Thank you guys,

    The problem is solved.
    You all were very helpfull and I appreciate it very much. You put me on the right track to tackle the problem. Thanks again.

    Raven

    Originally posted by rhs98
    try setting iRecID manually; this will allow you to narrow the problem down to this script; or the data being passed in. For example; replacing the line "...iRecID=request....." with
    Code:
    iRecId = 2

  14. #14
    Join Date
    Feb 2002
    Location
    San Francisco, CA
    Posts
    441
    thats what we're here for!
    Last edited by rhs98; 04-09-03 at 10:30.

Posting Permissions

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