我認爲錯誤可能來自我可能使用的保留字,但我不知道哪個字。上次我遇到這個問題是在INSERT INTO語句中,我通過在保留字周圍放置括號來修復它。但是,如果這是一個保留字的問題。當代碼是這樣的時候,我怎樣才能在保留字中加上括號?任何幫助?UPDATE語句中的語法錯誤
OleDbCommandBuilder cb;
cb = new OleDbCommandBuilder(clientAD);
DataRow dRow = clientDS.Tables["Client"].Rows[cInc];
bool thingy = false;
int defaultInt = 0;
byte defualtByte = 0;
double defualtDouble = 0.0;
#region dRow items
dRow["ID"] = textBox3.Text;
dRow["ID_Type"] = "";
dRow["LastName"] = textBox1.Text;
dRow["FrstName"] = "";
dRow["MI"] = "";
dRow["MassMail"] = thingy; //Bool
dRow["BusName"] = "";
dRow["Bus"] = thingy; //Bool
dRow["Title"] = "";
dRow["Title2"] = "";
dRow["Sex"] = "";
dRow["Cli_DOB"] = DateTime.Now.ToShortDateString(); //Date/Time
dRow["Spo_DOB"] = DateTime.Now.ToShortDateString(); //Date/Time
dRow["Salute"] = "";
dRow["Salute2"] = "";
dRow["Spouse"] = "";
dRow["SSAN"] = "";
dRow["Review"] = DateTime.Now.ToShortDateString(); //Date/Time
dRow["Occup"] = "";
dRow["AgentNo"] = defaultInt; //Int32
dRow["Status"] = "";
dRow["Wedding_DT"] = DateTime.Now.ToShortDateString(); //Date/Time
dRow["Flag_1"] = "";
dRow["Flag_2"] = "";
dRow["Flag_3"] = "";
dRow["Flag_4"] = "";
dRow["Flag_5"] = "";
dRow["Flag_6"] = "";
dRow["Flag_7"] = "";
dRow["Flag_8"] = "";
dRow["Flag_9"] = "";
dRow["Flag_10"] = "";
dRow["Group"] = thingy; //Bool
dRow["GroupMember"] = thingy; //Bool
dRow["KeyWords"] = "";
dRow["Smoker"] = "";
dRow["Married"] = "";
dRow["NumChild"] = defaultInt; //Int32
dRow["NetAsset"] = defaultInt; //Int32
dRow["Income"] = defualtByte; //Byte
dRow["LstUpdate"] = DateTime.Now.ToShortDateString(); //Date/Time
dRow["AutoSal"] = "";
dRow["CIP_ID"] = defaultInt; //Int32
dRow["EmailAddr_1"] = "";
dRow["EmailAddr_2"] = "";
dRow["UD1"] = "";
dRow["UD2"] = "";
dRow["UD3"] = "";
dRow["UD4"] = "";
dRow["UD5"] = "";
dRow["UD6"] = "";
dRow["UD7"] = "";
dRow["UD8"] = "";
dRow["UD9"] = "";
dRow["UD10"] = "";
dRow["UD11"] = "";
dRow["UD12"] = "";
dRow["UD13"] = "";
dRow["UD14"] = "";
dRow["UD15"] = defualtDouble; //Double
dRow["UD16"] = defualtDouble; //Double
dRow["UD17"] = defualtDouble; //Double
dRow["UD18"] = DateTime.Now.ToShortDateString(); //Date/Time
dRow["UD19"] = DateTime.Now.ToShortDateString(); //Date/Time
dRow["UD20"] = DateTime.Now.ToShortDateString(); //Date/Time
dRow["New"] = thingy; //Bool
dRow["TDate"] = DateTime.Now.ToShortDateString(); //Date/Time
dRow["TTime"] = DateTime.Now.ToShortDateString(); //Date/Time
dRow["ImportID"] = defaultInt; //Int32
dRow["SalespTxt"] = "";
dRow["Notepad"] = "";
dRow["ANote"] = "";
dRow["expCount"] = defaultInt; //Int32
dRow["PNote"] = "";
dRow["DrLic_Issue"] = DateTime.Now.ToShortDateString(); //Date/Time
dRow["DrLic_Exp"] = DateTime.Now.ToShortDateString(); //Date/Time
dRow["DrLic_state"] = "";
dRow["CoDrLic_State"] = "";
dRow["CoDrLic_Issue"] = DateTime.Now.ToShortDateString(); //Date/Time
dRow["CoDrLic_Exp"] = DateTime.Now.ToShortDateString(); //Date/Time
dRow["Void_check"] = "";
dRow["ASER"] = "";
dRow["Anniversery"] = "";
dRow["Client_Note"] = "";
dRow["C o_Citizenship"] = "";
dRow["Attachment"] = "";
dRow["Pass_Notes"] = "";
dRow["Other_Notes"] = "";
dRow["CE_Notes"] = "";
dRow["Comp_Notes"] = "";
#endregion
clientAD.Update(clientDS, "Client");
我將默認值放入行中,並檢查確保數據類型匹配。而我原本沒有包含字段名稱,而是第一次使用字段索引。
你能發佈錯誤代碼嗎? – czuroski 2012-02-03 20:15:43
執行此代碼時得到的Exact錯誤是什麼? – Akhil 2012-02-03 20:15:45
試着看'cb.GetUpdateCommand()。CommandText'? – Blorgbeard 2012-02-03 20:21:34