473,378 Members | 1,404 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,378 software developers and data experts.

importing data from an excel sheet to sql server express using c#

hi....i m fairly new to c#.net...i m trying to import data from an excel file to sql server using c#.....below here is my code....when i m executing this code i m getting an exception "ODBC CALL FAILED" i m not able to figure out where i hve gone wrong...so if any one could guide me i wil b thankful....




private void Import_btn_Click(object sender, EventArgs e)
{
try
{
string excelConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + openFile.FileName + ";Extended Properties=Excel 8.0";
// Create Connection to Excel Workbook
OleDbConnection connection = new OleDbConnection(excelConnectionString);
connection.Open();
OleDbCommand command = new OleDbCommand("INSERT INTO[ODBC;DRIVER ={SQLEXPRESS};SERVER=DASSDP-12\\SQLEXPRESS;DATABASE=mIO;Trusted Connection=Yes].Brand SELECT Brand FROM [BrandDefinition$A8:E9999]", connection);
command.ExecuteNonQuery();
connection.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
}

}
Dec 2 '08 #1
2 2964
akshaycjoshi
153 100+
OleDB provider for MS excel ?
Dont think it will work, i guess u will have to use System.IO or Excel library for that.
Dec 3 '08 #2
yes Oledb provider for excel.......
could u tel me if there is any other method.....
Dec 3 '08 #3

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

Similar topics

9
by: sifar | last post by:
Hi, I am right now learning PHP & want to know if there is a way to send web form data to an Excel sheet located on a network. My windows xp PC doesnot have a copy of Excel. Also i am not...
9
by: Edward S | last post by:
I budget for a Project in an Excel sheet as illustrated below. The months below are usually a 2 year period i.e. 24 months, though it could be over 24 months depending upon a Project. I then...
7
by: Darren | last post by:
I have been attempting to create a reservation planning form in excel that imports Data from an Access database and inserts that information automaticly into the correct spreed sheet and the...
9
by: jillandgordon | last post by:
I am trying to import an excel file into Access 97. It looks perfectly all right but, every time I try to import it, I get to the lst step and am told that it was not imported due to an error. ...
1
by: Vivek | last post by:
Hi all, I am trying to import data from an excel sheet to MSSQL server 2000 using a web application (C#). Since I have to validate the data in the excel sheet, the approach i have used is to get...
3
by: Conrad F | last post by:
Hello All, I know how to import a specific named excel sheet into a datagrid using ADO.NET by setting up a JET connection and then SELECTing data from the sheet. However, for a real world...
2
by: Snozz | last post by:
The short of it: If you needed to import a CSV file of a certain structure on a regular basis(say 32 csv files, each to one a table in 32 databases), what would be your first instinct on how to...
0
by: Anish G | last post by:
Hi All, I am getting the below given error while running my application in live server. In my local machine, its working fine. Please help me as it is very urgent for me. Exception from...
1
by: zamzoum | last post by:
hi i just wanted to ask u how can i solve the exception error "couldnot find installable ISAM" this exception occurs when i run this code : Dim excelConnection As...
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.