Import excel to sql
plz send some zip format of asp.net to import excel to sql...urgent and fast plz...
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Aug 2, 2013, 4:31 AM EDT
i am attaching modified code which will definitely work. check the attached code and reply
Mark it as answered if it helps you....
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 1, 2013, 10:52 PM EDT
Please refer this link
http://www.aspdotnet-suresh.com/2010/09/import-data-from-excel-to-sql-database.html
Regards,
Iftikar
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Aug 1, 2013, 10:58 PM EDT
http://csharpdotnetfreak.blogspot.com/2009/04/export-excel-data-sqlbulkcopy-aspnet.html
Amitesh VermaRank #2,535 · 552 reputationPosted Aug 1, 2013, 11:00 PM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 1, 2013, 11:04 PM EDT
Regards,
Iftikar
Amitesh VermaRank #2,535 · 552 reputationPosted Aug 1, 2013, 11:05 PM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 1, 2013, 11:09 PM EDT
Regards,
Iftikar
Amitesh VermaRank #2,535 · 552 reputationPosted Aug 1, 2013, 11:15 PM EDT
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Aug 1, 2013, 11:26 PM EDT
i modified your code just check the attachment.
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 1, 2013, 11:30 PM EDT
Regards,
Iftikar
Amitesh VermaRank #2,535 · 552 reputationPosted Aug 2, 2013, 12:39 AM EDT
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Aug 2, 2013, 12:45 AM EDT
refer to this link and follow these steps
http://www.aspdotnet-suresh.com/2013/01/c-microsoft-office-access-database.html
reply
Amitesh VermaRank #2,535 · 552 reputationPosted Aug 2, 2013, 1:13 AM EDT
//file upload path
string path = fileuploadExcel.PostedFile.FileName;
//Create connection string to Excel work book
string excelConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;Persist Security Info=False";
//Create Connection to Excel work book
OleDbConnection excelConnection =new OleDbConnection(excelConnectionString);
//Create OleDbCommand to fetch data from Excel
OleDbCommand cmd = new OleDbCommand("Select [CustomerID],[City],[Country],[PostalCode] from [Excel07$]",excelConnection);
excelConnection.Open();
OleDbDataReader dReader;
dReader = cmd.ExecuteReader();
SqlBulkCopy sqlBulk = new SqlBulkCopy(strConnection);
//Give your Destination table name
sqlBulk.DestinationTableName = "excelimport";
sqlBulk.WriteToServer(dReader); excelConnection.Close();
in this code..its showing..
The Microsoft Access database engine cannot open or write to the file ''. It is already opened exclusively by another user, or you need permission to view and write its data. ..
but this code doesnot have anyfolder to upload excel file in it...
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 2, 2013, 1:28 AM EDT
Regards,
Iftikar
Posted Aug 2, 2013, 1:30 AM EDT
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Aug 2, 2013, 2:03 AM EDT
i checked your code and modified. just check the attached file and run it.
1st open the .mdf file.
2nd match the table column name with exel column name.
Amitesh VermaRank #2,535 · 552 reputationPosted Aug 2, 2013, 2:24 AM EDT
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Aug 2, 2013, 2:25 AM EDT
Amitesh VermaRank #2,535 · 552 reputationPosted Aug 2, 2013, 2:33 AM EDT
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Aug 2, 2013, 2:48 AM EDT
check this line of code
OleDbCommand cmd = new OleDbCommand("Select [CustomerID],[City],[Country],[PostalCode] from [Sheet1$]", excelConnection);
modify your code and reply.
if it help you mark it as answered.
Amitesh VermaRank #2,535 · 552 reputationPosted Aug 2, 2013, 2:53 AM EDT
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Aug 2, 2013, 2:58 AM EDT
Amitesh VermaRank #2,535 · 552 reputationPosted Aug 2, 2013, 3:58 AM EDT
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Aug 2, 2013, 4:02 AM EDT
which browser you are using...
Sunny SharmaRank #223 · 11.1K reputationPosted Aug 2, 2013, 4:12 AM EDT
The appropriate user account (NETWORK SERVICE by default) needs MODIFY permissions on the folder that the Excel file sits in.
Right Click on the folder where your Excel file lies.
Goto Security > Edit >Add.
Find and Add NETWORK_SERVICE account. Click OK. Assign all the permissions to this account and try to run your application.
Feedback awaited.
Hope it helps.
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 2, 2013, 4:13 AM EDT
Regards,
Iftikar
Amitesh VermaRank #2,535 · 552 reputationPosted Aug 4, 2013, 7:58 PM EDT