I am trying to insert records into an Access table from a SQL database. When I step through, I add 5 rows but when I am done, the rows aren't in the table. I know I am missing something easy, but I sure can't figure it out.
OdbcConnection ocn = new OdbcConnection
("Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\\my.mdb;Uid=Admin;Pwd=;");
ocn.Open();
OdbcDataAdapter adapter = new OdbcDataAdapter
(@"SELECT * FROM FROM Nodes Order by Node ASC", ocn);
da.InsertCommand = new OdbcCommand(@"INSERT INTO NODES(Node,Descriptor,NDisabled,GroupNum,LocalAddress
TurnOffPolling,CommOffSig,MaintSig,CollectAuditSig,SkipHistory,KeepAwake,DialUp,KeepAwakeDate,ModelNumber)
VALUES(@Node,@Descriptor,@NDisabled,@Groupnum,@LocalAddress,
@TurnOffPolling,@CommOffSig,@maintSig,@CollectAuditSig,@SkipHistory,@KeepAwake,@DialUp,@KeepAwakeDate,@ModelNumber)", ocn);
da.InsertCommand.Parameters.Add("@Node", OdbcType.VarChar);
da.InsertCommand.Parameters.Add("@Description", OdbcType.VarChar);
da.InsertCommand.Parameters.Add("@NDisabled", OdbcType.Bit);
da.InsertCommand.Parameters.Add("@GroupNum", OdbcType.Int);
da.InsertCommand.Parameters.Add("@LocalAddress", OdbcType.Int);
da.InsertCommand.Parameters.Add("@TurnOffPolling", OdbcType.Bit);
da.InsertCommand.Parameters.Add("@CommOffSig", OdbcType.VarChar);
da.InsertCommand.Parameters.Add("@MaintSig", OdbcType.VarChar);
da.InsertCommand.Parameters.Add("@CollectAuditSig", OdbcType.VarChar);
da.InsertCommand.Parameters.Add("@SkipHistory",OdbcType.Bit);
da.InsertCommand.Parameters.Add("@KeepAwake",OdbcType.Bit);
da.InsertCommand.Parameters.Add("@DialUp",OdbcType.Bit);
da.InsertCommand.Parameters.Add("@KeepAwakeDate",OdbcType.VarChar);
da.InsertCommand.Parameters.Add("@ModelNumber",OdbcType.Int);
DataTable tbl = new System.Data.DataTable();
adapter.Fill(tbl);
while(SqlDataReader.Read())
{
DataRow nrow = tbl.NewRow();
nrow["Node"] = rdr["Node"];
tbl.Rows.Add(nrow); //I see the tbl.Rows.Count increase by one here
}
tbl.AcceptChanges();
adapter.Update(tbl);
ocn.Close();
When I open the table, the records aren't in the table. Can somebody tell me what I'm doing wrong here please?
Thanks in advance, Bob