Hi
Could someone point me in the right direction. Im trying to update an
Access DB using the code below, it seems to all run correctly and I
dont get any error messages, however it doesnt actually add the data
to the table. Any ideas where im going wrong.
private void button1_Click(object sender, EventArgs e)
{
OleDbDataAdapter da = new OleDbDataAdapter("SELECT
[Investment Type],ProjectName,[Extension Size],FinancialYear FROM
InvestmentHistory where [Store ID] = 225",
"Provider=Microsoft.JET.OLEDB.4.0;data source=C:\\Programme DB\
\Investment Programme_be.mdb");
DataSet ds = new DataSet();
da.Fill(ds, "InvestmentHistory");
OleDbConnection connection =
(OleDbConnection)da.SelectCommand.Connection;
DataTable dt = new DataTable("InvestmentHistory");
da.InsertCommand = connection.CreateCommand();
da.InsertCommand.CommandText = "Insert into
InvestmentHistory ([Investment Type],[ProjectName],[Extension Size],
[FinancialYear]) values ('Extension','CNF',2000,0)";
da.InsertCommand.Parameters.Add("Investment Type",
OleDbType.Char, 0, "Store ID");
da.InsertCommand.Parameters.Add("ProjectName",
OleDbType.Char, 0, "ProjectName");
da.InsertCommand.Parameters.Add("Extension Size",
OleDbType.Integer, 0, "Extension Size");
da.InsertCommand.Parameters.Add("FinancialYear",
OleDbType.Integer, 0, "FinancialYear");
da.Update(ds, "InvestmentHistory");
ds.AcceptChanges();
MessageBox.Show("Updated.");
}
There are actually more fields in the table than are being inserted
here, do i need to add default values for them?
Thanks for any suggestions.
Paul