473,406 Members | 2,220 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,406 software developers and data experts.

Import the Excel 2002 data into sql server 2000 using ado.net1.1

Hi ,

Any one can guide me in Import the Excel 2002 data into sql server 2000 using ado.net1.1. I have searched all the forums most of the solutions end with a line of suggestion not with any code .

here is my code . by using OLEDB JET I got the data from Excel to data set , the data is in the data table

OleDbConnection strConn = new OleDbConnection ("Provider=Microsoft.Jet.OLEDB.4.0;data source= c:\\1005.xls;Extended Properties=\"Excel 8.0;HDR=YES\"");
OleDbDataAdapter myCommand = new OleDbDataAdapter("SELECT * FROM [sheet1$]",strConn);
DataSet dataSet = new DataSet();
myCommand.Fill(dataSet);
DataTable mytable;
mytable= dataSet.Tables[0];

I can view this data on the datagrid .

now I want to transfer this data in to SQL server . I tryed as below but I was end up with nothing

if(mytable.Rows.Count>0)
{
try
{
// connect to sql andinsert the data
OleDbConnection conn = new OleDbConnection ("Provider=SQLOLEDB;Data Source=;Initial Catalog=;");


I was end up here just by making connection to SQL server . Can some one assist me further . I am a beginner.I tryed loop like this


foreach (DataRow dr in mytable.Rows)
{
foreach (DataColumn dc in mytable.Columns)
{
string val = dr[dc].ToString();
Response.Write(val);
}




I can see the string values but no ides how to transfer the data in the table "mytable ' in to sql server
Jan 4 '07 #1
4 2244
kenobewan
4,871 Expert 4TB
You need a dataadapter:
Expand|Select|Wrap|Line Numbers
  1. DataAdapter.Update(dataset);
Update will have to be configured for the dataadapter. If you are using VS this will help alot with the setup.

Hope that this helps.
Jan 5 '07 #2
Thanks for the reply .

I used
DataAdapter.Update (dataset, "source table );

It is not working
Jan 5 '07 #3
kenobewan
4,871 Expert 4TB
Did you set up the update for the dataadapter? Are you using VS? Did you get an error?
Jan 5 '07 #4
Ys I am using VS
I tryed these methods,

DataAdapter.Updata(dataset,"sourceTable");

my code

OleDbDataAdapter excelda = new OleDbDataAdapter("SELECT * FROM [sheet1$]",excelConn);
DataSet excelds = new DataSet(); excelda.Fill(excelds,"sheet1$");
DataTable excelTable = excelds.Tables["sheet1$"];
//creae new sql adapter that is used to build a dataset
SqlDataAdapter sqlda = new SqlDataAdapter ("select *from tempdata",sqlConn)
SqlCommandBuilder x = new SqlCommandBuilder (sqlda);
sqlda.Update (excelds,"tempdata");
Response.Write (" data is loaded");

Tempdata table in sql is empty .
Jan 5 '07 #5

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

Similar topics

3
by: Elaksomfan | last post by:
Hi, I am having trouble importing data from an excel spreadsheet into MS SQL Server 2000 using DTS Wizard. The DTS import process is successfull, no errors, but only 50 rows of approx. 1500 rows...
1
by: Richard Holliingsworth | last post by:
Hello: Thanks for your quick response. I'm trying to import a new Excel file into an A2K table and it's truncating the data. One of the Excel columns is a text field that can be up to 2000...
4
by: D | last post by:
I've created a report with many subreports of aggregate data. I want my client to be able to export this data to Excel to make her charts, etc. Only one problem: one of the fields is a "SchoolYear"...
5
by: Johnny Meredith | last post by:
I have seven huge fixed width text file that I need to import to Access. They contain headers, subtotals, etc. that are not needed. There is also some corrupt data that we know about and can...
17
by: Mansi | last post by:
I need to do some research on how to use excel automation from c#. Does anyone know of any good books related to this subject? Thanks. Mansi
2
by: Sreedhar Vankayala | last post by:
Hi, I joined a project where we need to import data from a excel file into sql server via the asp.net. After doing a long research found that #1. Upload Excel file to the server #2. Load or...
3
by: Boris Condarco | last post by:
Hi gurus, I'm using excel 2000 to show data that comes from datagrid. The problem is that for any reason the asp.net application maintains the excel open, even though, i do close it. Besides,...
3
by: Schultz | last post by:
I would like to know if it is possible to import data from MS Excel 2000 to a dataset using asp.net. The excel file would need to be uploaded to the server from a web page first, before the loaded...
0
by: jayfeb29 | last post by:
Can any one help me with importing excel data into sql server using ado.net and c#
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
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...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.