473,324 Members | 2,257 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Import Excel Sheet datas into mysql

7
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.
May 16 '07 #1
3 6662
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.
it seems u r very lucky... i m facing similar prob.... i m workin on vb but i came accross some links that can b of use 2 u..... go thru dem...


http://www.aspfree.com/c/a/ASP.NET-Code/Read-Excel-files-from-ASPNET/

http://support.microsoft.com/default.aspx?scid=kb;en-us;306572

best of luk...
May 16 '07 #2
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.

You can also see my posts for more information... it is on dis page only wid d same topic name
Best Wishes
Mayank Vats
May 16 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Phil Perrin | last post by:
------=_NextPart_000_0001_01C3663D.5E3EAD70 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit I'm a relative newbie to MySql, and I've got a small project I'm working...
8
by: Nick M | last post by:
Hello All, Excellent info here Thanks! I am very new to using access in general and I am on a learning curve. I'm trying to import an excel workbook (with worksheets) into an access db via a...
6
by: jw | last post by:
i have datas in an excel file like this: names surnames jack white smith black marry brown how can i read these datas for ex i know that names in the cell A1 and surnames is...
1
by: Peter Stojkovic | last post by:
I am importing data from an EXCEL XLS-File via OLEDB-Provider The command is SELECT * from Everything works fine if the first sheet is named sheet1 But sometimes the name is not known...
2
by: madeleine | last post by:
I'm hoping the answer to this is that I'm just doing something silly, but I'm really scratching my head over this one. I'm importing data from multiple workbooks, each workbook has a sheet called...
8
by: FireGeek | last post by:
I have a database that is split appropriately. Annually, we need to add data from .xls files. I have added code so with a click of a button, it will import this data as a new table into the...
6
by: vj83 | last post by:
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,...
5
by: Sport Girl | last post by:
Hi everybody. I am new in PERL language and working in it since little hours, actually i am still a trainee and i need help please. In fact, i need a script in PERL that enables me to retrieve...
1
by: Sport Girl | last post by:
Hi everybody , i have the task of developing in Perl a script that retrieves data from 3 tables ( bugs, profiles, products) from a MySQL database called bugs and display them in an excel sheet...
7
by: TG | last post by:
hi! I am trying to create a sql server table from an excel sheet. Here is the code I have: 'This procedure the xlsx file and dumps it to a table in SQL Server
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.