Insert Excel data into the MySQL database? Hello,
I have a C #. NET application where I read data from excel and displayed in a datagrid in my ASPX form.
The code is here
private void Button2_Click (object sender, System.EventArgs e)
(
try
(
strConnect string = @ "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C: \ \ Salary.xls; Extended Properties =" "Excel 8.0; HDR = YES ;""";
OleDbConnection conn = new OleDbConnection (strConnect);
/ / Conn.Open ();
OleDbCommand command = new OleDbCommand ("SELECT * FROM [Sheet1"], $ conn);
/ / Command.Connection = conn;
/ / = Command.CommandType CommandType.Text;
/ / Command.CommandText = "SELECT * FROM [Sheet1]";
OleDbDataAdapter da = new OleDbDataAdapter (command);
DataSet ds = new DataSet ();
/ / Dt = new DataTable ();
conn.Open ();
da.Fill (ds, "EmpSal");
DS = DataGrid1.DataSource;
DataGrid1.DataBind ();
/ / Da.Fill (dt);
conn.Close ();
lblError.Text = "The Excel spreadsheet has been read";
/ Dt / performance;
)
catch (Exception ex)
(
Response.Write (ex.Message);
/ Null / return;
)
)
the thing is that I need to download the data in the table of MySQL database. pls can someone help me with C #. NET. I need to use only the MySQL database. (Coz we r using mysql database in our project)
Cordially
Vijay.
I'm not familiar with C # syntax. I use PHP to interface with MySQL.
In any case, using the INSERT SQL and / or CREATE would be similar to the way you read from Excel with OLE.
The difference is with your DB connect statement.
These links may be helpful:
http://www.devhood.com/tutorials/tutoria ...
http://csharp.codenewbie.com/articles/cs ...
http://www.codeproject.com/cs/database/A ...
Posted on February 7, 2010.