I am trying to use LINQPad to query an MS Access table using DataSet, and wanted to insert the query result to a SQL table.
This is how I got the data from the MS Access table:
string connectionString = ("Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=C:\\Temp\\temp.mdb;");
OdbcConnection myconnection = new OdbcConnection(connectionString);
OdbcDataAdapter myadapter = new OdbcDataAdapter("SELECT * FROM Name", myconnection);
DataSet myCustomersDS = new DataSet();
myadapter.Fill(myCustomersDS, "Name");
Now In LINQPad, I wanted to insert all records from the dataset myCustomersDS to a SQL table. I tried to query the dataset in LINQPad this way and it gives me the right result:
Connection.Open();
var toInsert = from b in myCustomersDS.Tables["Name"].AsEnumerable()
select b;
toInsert.Dump();
Connection.Close();
I tried various versions of these commands, but always get errors related to the type of the DataSet not matching with the table type.
Name.InsertOnSubmit(toInsert);
SubmitChanges();
Thank you, Steven
