Hi,
I have a C#.net application in which i have read the datas from excel sheet and displayed in a datagrid in my Aspx form.
The code is here
private void Button2_Click(object sender, System.EventArgs e)
{
try
{
string strConnection = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Salary.xls;Extended Properties=""Excel 8.0;HDR=YES;""";
OleDbConnection conn = new OleDbConnection(strConnection);
//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();
//DataTable dt = new DataTable();
conn.Open();
da.Fill(ds, "EmpSal");
DataGrid1.DataSource=ds;
DataGrid1.DataBind();
//da.Fill(dt);
conn.Close();
lblError.Text="The Excel sheet has been read";
//return dt;
}
catch (Exception ex)
{
Response.Write( ex.Message);
//return null;
}
}
the thing is that i have to upload the datas into the mysql database table. can anybody pls help me with the C#.net code. i need to use only mysql database.(coz we r using mysql db in our project)
Regards
Vijay.
Insert excel datas in mysql database?
I'm not familiar with C# syntax. I use PHP for interfacing with MySQL.
In any case, using the SQL INSERT and/or CREATE statements would be similar to how you're reading from the excel with OLE.
The difference would be 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...
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment