Reputation: 45
i want to insert my xls file sheet into the ODBC server in c# .....kindly help me out with its c# coding....I can only find sql server related problems in the internet as i want to work in ODBC. this is my coding :-
string ConnectionString, str;
OdbcConnection con;
OdbcCommand cmd;
SqlBulkCopy bkcp ;
private void btnSend_Click(object sender, EventArgs e)
{
string ConnectionString = "Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=ak_db.excel_table;Uid=root;Pwd=root";
using (OdbcCommand cmd = new OdbcCommand(ConnectionString))
{
OdbcCommand command = new OdbcCommand("Select * FROM [Sheet1$]", con);
con.Open();
// Create OdbcDataReader to Data Worksheet
using (OdbcDataReader dr = cmd.ExecuteReader())
{
// SQL Server Connection String
string OdbcConnectionString = "Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=ak_db.excel_table;Uid=root;Pwd=root";
}
i dont know what to do after this ...so kindly help me out....
Upvotes: 0
Views: 151
Reputation: 1928
One way to go is to read the values from your excel file and store them in a dataset like described here:
Reading-Excel-Files-From-C-Sharp
and then writing this dataset to your online database:
Good Luck!
Upvotes: 1