2014-01-22 43 views
-2

任何人都可以幫我解決這個錯誤嗎?SQL查詢中的令牌錯誤

解析查詢時出錯。 [令牌行號= 1,令牌行偏移= 628,令牌在錯誤=數據]

private DateTime data() 
{ 
    DateTime datasot = DateTime.Now; 
    string d = datasot.ToString("M/d/yyyy"); 
    DateTime dd = DateTime.Parse(d); 
    return dd; 
} 

string komanda = "UPDATE ditari SET [email protected], [email protected], [email protected]," + 
     "[email protected], [email protected], [email protected], [email protected]," + 
     "[email protected], [email protected], [email protected], [email protected]," + 
     "[email protected], [email protected], [email protected], [email protected]," + 
     "[email protected],[email protected],[email protected]," + 
     "[email protected], [email protected]" + 
     "WHERE data='"+data()+"'"; 

SqlCeConnection sq = new SqlCeConnection(Connection.connectionstring); 
SqlCeCommand sc = new SqlCeCommand(komanda, sq); 
try 
{ 
    sq.Open(); 
    sc.Parameters.AddWithValue(@"id", Qasja.ID); 
    sc.Parameters.AddWithValue(@"namazisabahut", cbnamazisabahut.SelectedItem.ToString()); 
    sc.Parameters.AddWithValue(@"namazidrekes", cbnamazidrekes.SelectedItem.ToString()); 
    sc.Parameters.AddWithValue(@"namaziikindise", cbnamaziikindise.SelectedItem.ToString()); 
    sc.Parameters.AddWithValue(@"namaziakshamit", cbnamaziakshamit.SelectedItem.ToString()); 
    sc.Parameters.AddWithValue(@"namazijacise", cbnamazijacise.SelectedItem.ToString()); 

    sc.Parameters.AddWithValue(@"dymbedhjeterekatesunnet", chkdymbedhjetrekatesunnet.CheckState); 
    sc.Parameters.AddWithValue(@"namaznate", chkNamazNate.CheckState); 
    sc.Parameters.AddWithValue(@"leximikuranit", chkLeximiKuranit.CheckState); 
    sc.Parameters.AddWithValue(@"ndegjimikuranit", chkLeximiKuranit.CheckState); 
    sc.Parameters.AddWithValue(@"ndegjimidersit", chkNdegjimiDersit.CheckState); 
    sc.Parameters.AddWithValue(@"mekatet", txtpershkrimimekatit.Text); 
    sc.Parameters.AddWithValue(@"mesimilenda", txtmesimilenda.Text); 
    sc.Parameters.AddWithValue(@"mesimior", nud_saorkenimsu.Value); 
    sc.Parameters.AddWithValue(@"mesimipershkrimi", txtpershkrimiMsimit.Text); 
    sc.Parameters.AddWithValue(@"akeniqenepune", chkAkeniqenepune.CheckState); 
    sc.Parameters.AddWithValue(@"punepershkrimi", txtPershkrimiPuna.Text); 
    sc.Parameters.AddWithValue(@"pershkrimishkurterditor", richtextPershkrimiDitor.Text); 
    sc.Parameters.AddWithValue(@"dhikrimengjesitdhembremjes", cbdhikrimengjesitmbremjes.SelectedItem.ToString()); 
    sc.Parameters.AddWithValue(@"estagfirullah", chkEstigfar.CheckState); 
    sc.Parameters.AddWithValue(@"salavatet", chksalavatet.CheckState); 
    sc.ExecuteNonQuery(); 
    sc.Dispose(); 
    sq.Close(); 
+1

檢查字符串科曼達產生有效的SQL –

回答

2

有前一丟失空間「WHERE」在查詢中。

+0

的一個快速方法看到的是讀取錯誤信息:當你看到你的查詢的值,並在第1行(只有1行)和字符628,它只是在WHERE之後。所以你知道你的問題離這個地方不遠。 – krimog

0

你已經錯過了近空間,

讓你查詢這個樣子

enter image description here

所以它不能被解析。

你必須改變這樣的

"UPDATE ditari SET [email protected], [email protected], [email protected]," + 
     "[email protected], [email protected], [email protected], dymbedhjeterekatesu[email protected]," + 
     "[email protected], [email protected], [email protected], [email protected]," + 
     "[email protected], [email protected], [email protected], [email protected]," + 
     "[email protected],[email protected],[email protected]," + 
     "[email protected], [email protected] " + 
     " WHERE data='"+data()+"'"; 

現在它看起來像這樣

enter image description here

希望這有助於你

相關問題