SQL Server Performance

SQL QUERY PROBLEM

Discussion in 'ALL SQL SERVER QUESTIONS' started by bobykuriakose12, Jul 8, 2013.

  1. bobykuriakose12 New Member

    i doing one project in vb and access 2003.
    i have a plan to create one query for date search...i have one table and 5 fields(field names is amddate,amddate1,amddate2,total,sample)

    **my requirement is** ----if i enter any date on (dtpamdsrh.Value),query check the sam and jdate data field.if that date found in sam and jdate,shown in result.. can you please check this...

    Attached Files:

  2. davidfarr Member

    There are a few things here to look at;
    This is a SQL Server forum. The error you describe is not a SQL Server error. The error is being caused by incorrect VB or VBA syntax.
    Are you actually connecting to a SQL server database ? ..or to an MS Access database ?
    T-SQL syntax has some small but important differences between MS Access and SQL Server. With SQL Server; you should not enclose your date values in hash tags (#) but rather within single quotes ('), similar to a string or text value.

    You also clearly have incorrect syntax in the Recordset.Open method; there is a comma out of place where the "ds4" part is and this fault is incorrectly encapsulating your VB Recordset parameters as part of the T-SQL query, as evidenced by the closed quotation character at the end of the code line in your attached image.
    You can perhaps try;
    Code:
    Set rs4 = New Recordset
    rs4.Open "select * from employeeentry WHERE sam = '" & Format(dtpamdsrh.Value, "dd-mm-yyyy") & "' AND jdate = '" & Format(dtpamdsrh.Value, "dd-mm-yyyy") & "'",ds4, adOpenStatic, adLockOptimistic
    

Share This Page