Results 1 to 4 of 4

Thread: Commas in SQL Expression

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441
    my problem:

    Dim EName As String

    EName = "Stanich JR, James A"

    Dim cnn As New ADODB.Connection
    Dim rst As New ADODB.Recordset

    cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
    "Data Source=" & TimeDatabase

    rst.Open _
    "Select EmployeeFull from Employee_Info where_ EmployeeFull='" & EName & "'"" _
    , cnn, adOpenStatic, adLockPessimistic

    I keep getting a syntax error.

    Any suggestions?
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    I think the problem is in the WHERE clause. You have extra double quote.

    Code:
    Dim strName As String 
    Dim cn As New ADODB.Connection 
    Dim rs As New ADODB.Recordset 
    Dim strSQL As String
    
    strName = "Stanich JR, James A" 
    
    cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _ 
    "Data Source=" & TimeDatabase 
    
    strSQL = "Select EmployeeFull from Employee_Info Where EmployeeFull='" & strName & "'" 
    
    rs.Open  strSQL, cn, adOpenStatic, adLockPessimistic

  3. #3
    Fanatic Member Stevie's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    565
    Try removing the last " from the SQL statement.

    [Couldn't quite get in before Serge!!]

    [Edited by Stevie on 09-26-2000 at 11:00 AM]
    VB6 sp5, SQL Server 2000, C#

    There are no stupid questions. Only stupid people.

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Thank you both

    It happened to be he damn ". Thanks guys.
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

Posting Permissions

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



Click Here to Expand Forum to Full Width