Need Help with SQL & Access

Results 1 to 2 of 2

Thread: Need Help with SQL & Access

  1. #1
    Join Date
    Dec 1969
    Posts
    11

    Default Need Help with SQL & Access

    I have a database in which I want to add new data from<BR>a form. I have a session with the name "gotname" which is an<BR>employee number passed on from previous pages. I am using this code as the connection:<BR>Set Jobrs = Server.CreateObject("ADODB.Recordset")<BR>strsql = "Select * From project Where Emp=(&#039" & gotname & "&#039)"<BR>Jobrs.Open strsql, Connect, adOpenDynamic, adLockOptimistic<BR><BR>I keep getting this error:<BR>Microsoft OLE DB Provider for ODBC Drivers error &#039 80040e07&#039 <BR>[Microsoft][ODBC Microsoft Access 97 Driver] Data type mismatch in criteria expression.<BR><BR>How can I get the "Emp" to recognize the number that I want is <BR>"gotname"

  2. #2
    Join Date
    Dec 1969
    Posts
    94

    Default RE: Need Help with SQL & Access

    If &#039gotname&#039 is the field name in the form, then try this:<BR>// if the form is &#039get&#039, use &#039request.querystring&#039, if it is <BR>// &#039post&#039 use &#039request.form&#039. I will be using the &#039get&#039 method.<BR>vargotname = request.querystring <BR>.<BR>.<BR>.<BR>// If &#039gotname&#039 is a other than text, don&#039t use the apostrophe.<BR>// Also, make sure that &#039Emp&#039 is considered &#039text&#039 in Access.<BR>strsql = "Select * From project Where Emp = &#039" & gotname & "&#039"<BR><BR>Hope that helps, if it doesn&#039t repost your problem or questions.<BR><BR>

Posting Permissions

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