2016-02-12 36 views
-1

我有這個錯誤,每當我執行我的程序時,「在第1行」附近使用正確的語法「錯誤出現。在第1行''附近使用正確的語法

這是我試圖執行的查詢。

Connection(); 
sql_connect.Open(); 

string date_start = dateTimePicker_starting.Value.ToString(); 
string date_to = dateTimePicker_to.Value.ToString(); 
string empid = textBox_empid.Text; 


sql_command = new MySqlCommand("select sum(lt_min_hours) as Total_Late from tbl_late where (late_date between '" + date_start + "' and '" + date_to + "' and empid = " + empid + ";", sql_connect); 
sql_reader = sql_command.ExecuteReader(); 

我檢查了',並且它都有它的一對。 請healp。我是mysql新手。

謝謝!

+2

無需添加'「」' –

+0

我刪除,但仍然出現了錯誤。 – mimi

+0

你的參數值是什麼? –

回答

0

我想你錯過了右括號和sql_command線將

sql_command = new MySqlCommand("select sum(lt_min_hours) as Total_Late from tbl_late where (late_date between '" + date_start + "' and '" + date_to + "') and empid = " + empid + ";", sql_connect); 
+0

哦,是的!我沒有注意到這一點。謝謝!現在它工作正常。 – mimi

相關問題