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.
6 4450
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.
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.
Atli 5,058
Expert 4TB
Moved to the .Net forums. And I edited the title.
MODERATOR
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.
Couldnt you just change your SELECT * FROM [SHEET1] to something like UPDATE [SHEET1] ... and fill in the rest with the needed sql statement to update it?
Also, on a side note, I would consider refactoring your code a bit. You are mixing a lot of elements into one snippet.
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |