c# - how to convert output of MY SQL Query to Access Database -


in project need extract output of mysql query ms access database. mean ever output of mysql query should go ms access databse in table t1. has no more tables 1 table. have converted sqlquery datatable. how can write datatable msaccess table t1 using c# :

myconnection.connectionstring = myconnectionstring;  odbccommand cmd= new odbccommand();  cmd.commandtype= commandtype.text;  myconnection.open();  (int = 0; < datatable.rows.count; i++) {    cmd.commandtext = "insert t1 (column1) values ('" +      datatable.rows[i].itemarray.getvalue(0) + "')"; cmd.executenonquery();  }  

i assume exception message saying you don't have valid connection, because not assigning valid connection odbccommand, try initializing odbccommand in way :

odbccommand cmd= new odbccommand(commandtype.text, myconnection);  

and use query parameter instead of string query concatenation ...


Comments