I get some code here:
<br />
<br />
public class p<br />
{<br />
private static string _ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=.\\IncomeAExpenditure.accdb";<br />
<br />
public static void Execute(string pSqlString)<br />
{<br />
OleDbConnection oleDbConn = new OleDbConnection(_ConnectionString);<br />
oleDbConn.Open();<br />
<br />
OleDbCommand cmd = new OleDbCommand(pSqlString, oleDbConn);<br />
<br />
try<br />
{<br />
cmd.ExecuteNonQuery();<br />
}<br />
catch (Exception ex)<br />
{<br />
throw ex;<br />
}<br />
finally<br />
{<br />
oleDbConn.Close();<br />
}<br />
}<br />
}<br />
<br />
string sql = String.Format("INSERT INTO P00001(quyenso, so, no, co, hoten, diachi, lydochi, sotien, sotienbangchu, kemtheo, chungtugoc, ngaythuchi) VALUES('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', {7}, '{8}', '{9}', '{10}', '{11}')", txtQuyenSo.Text, txtSo.Text, txtNo.Text, txtCo.Text, txtHoTen.Text, txtDiaChi.Text, txtLyDoChi.Text.Replace("\r\n", String.Empty), txtSoTien.Value, txtSoTienBangChu.Text.Replace("\r\n", String.Empty), txtKemTheo.Text, txtChungTuGoc.Text, txtNgayThuChi.Value.ToString(STR_YyyyMMdd));<br />
<br />
p.Execute(sql);<br />
This is database access structure
maso (auto number)
ngaythuchi (date/time)
quyenso (text)
so (text)
no (text)
co (text)
hoten (text)
diachi (text)
lydochi (text)
sotien (Number)
sotienbangchu (text)
kemtheo (text)
chungtugoc (text)
When i run execute, i can not insert or update. But i copy sqlstring and run it in access, it is ok.
Help me find error. I can not find this error.