-4

I have problem with this code the error is incorrect syntax near ,., this the code please help.

String sql = @"select
            C_Date,
            L_UID,
            min(C_Time) as [login],
            max(C_Time) as [logout]
   from
            tEnter
   where
            L_UID = "+txtEmpName+"
       and
            C_Date between '" + dtfrom + "' and '" + dtto + "'
   group by
            C_Date,
            L_UID";
Jodrell
  • 34,946
  • 5
  • 87
  • 124
  • there isnt a '.' in the code you have provided – dbajtr Aug 30 '17 at 07:49
  • 1
    `[login]` is an invalid identifier in (standard) SQL –  Aug 30 '17 at 07:50
  • You have not enclosed txtEmpName into quotes. – Arvo Aug 30 '17 at 07:50
  • how explain more – Sabri Bamerhool Aug 30 '17 at 07:51
  • Suggestion: replace the sql-standards tag with the tag for the dbms you're actually using. (sql-server?) – jarlh Aug 30 '17 at 07:52
  • could please rewrite correct code with quotation I wrote this code in sql query and it works but here I change some parameter like textbox – Sabri Bamerhool Aug 30 '17 at 07:53
  • 1
    Your question shows minimal effort. Stack Overflow is not a debugging service for those who can't be bothered to format their code correctly or provide a working example. Additionally I suspect your code is highly susceptible to SQL injection attacks https://stackoverflow.com/questions/601300/what-is-sql-injection – Jodrell Aug 30 '17 at 08:03
  • Is this ... A debugging request? Yes, Minimal? Yes, Complete? No, Verifiable, No. Therefore this is not a valid question. https://stackoverflow.com/help/mcve – Jodrell Aug 30 '17 at 08:08

1 Answers1

1

Wild guess: txtEmpName is a text field, perhaps 'Wile E. Coyote'. The way the string is constructed, txtEmpName needs to be enquoted, and it isn't. The SQL parser catches the problem when it hits the unquoted .

Mischa
  • 2,240
  • 20
  • 18