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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sanjeeb LenkaPosted Aug 2, 2013, 8:31 AM
i am attaching modified code which will definitely work. check the attached code and reply
Mark it as answered if it helps you....
Amitesh VermaPosted Aug 4, 2013, 11:58 PM
Iftikar HussainPosted Aug 2, 2013, 8:13 AM
Regards,
Iftikar
Sunny SharmaPosted Aug 2, 2013, 8:12 AM
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.
Sanjeeb LenkaPosted Aug 2, 2013, 8:02 AM
which browser you are using...
Amitesh VermaPosted Aug 2, 2013, 7:58 AM
Sanjeeb LenkaPosted Aug 2, 2013, 6:58 AM
Amitesh VermaPosted Aug 2, 2013, 6:53 AM
Sanjeeb LenkaPosted Aug 2, 2013, 6:48 AM
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 VermaPosted Aug 2, 2013, 6:33 AM
Sanjeeb LenkaPosted Aug 2, 2013, 6:25 AM
Amitesh VermaPosted Aug 2, 2013, 6:24 AM
Sanjeeb LenkaPosted Aug 2, 2013, 6:03 AM
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.
Posted Aug 2, 2013, 5:30 AM
Iftikar HussainPosted Aug 2, 2013, 5:28 AM
Regards,
Iftikar
Amitesh VermaPosted Aug 2, 2013, 5:13 AM
//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...
Sanjeeb LenkaPosted Aug 2, 2013, 4:45 AM
refer to this link and follow these steps
http://www.aspdotnet-suresh.com/2013/01/c-microsoft-office-access-database.html
reply
Amitesh VermaPosted Aug 2, 2013, 4:39 AM
Iftikar HussainPosted Aug 2, 2013, 3:30 AM
Regards,
Iftikar
Sanjeeb LenkaPosted Aug 2, 2013, 3:26 AM
i modified your code just check the attachment.
Amitesh VermaPosted Aug 2, 2013, 3:15 AM
Iftikar HussainPosted Aug 2, 2013, 3:09 AM
Regards,
Iftikar
Amitesh VermaPosted Aug 2, 2013, 3:05 AM
Iftikar HussainPosted Aug 2, 2013, 3:04 AM
Regards,
Iftikar
Amitesh VermaPosted Aug 2, 2013, 3:00 AM
Sanjeeb LenkaPosted Aug 2, 2013, 2:58 AM
http://csharpdotnetfreak.blogspot.com/2009/04/export-excel-data-sqlbulkcopy-aspnet.html
Iftikar HussainPosted Aug 2, 2013, 2:52 AM
Please refer this link
http://www.aspdotnet-suresh.com/2010/09/import-data-from-excel-to-sql-database.html
Regards,
Iftikar