Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 25, 2012 08:38 AM by John Bhatt
Nov 23, 2012 05:27 AM|LINK
I have developed an application and in a web form, I have to upload data from Excel file and save it to database.
It works perfect to Display records in Grid but while I try to save data using SqlBulkCopy command, it is throwing error telling something like , Server Version.
I want to know, what will be the Version of Server in case if user has installed Microsoft Office 365/ 2013 in their machine and we are using OleDB Connection from Access or Excel.
Nov 23, 2012 07:14 AM|LINK
Check if the below code helps you, I am using this in my appl.
public static string ExcelConnectionString(string filePath)
OleDbConnectionStringBuilder sbConnection = new OleDbConnectionStringBuilder();
String strExtendedProperties = String.Empty;
sbConnection.DataSource = filePath;
if (Path.GetExtension(filePath).Equals(".xls"))//for 97-03 Excel file
sbConnection.Provider = "Microsoft.Jet.OLEDB.4.0";
strExtendedProperties = "Excel 8.0;HDR=Yes;IMEX=1";//HDR=ColumnHeader,IMEX=InterMixed
else if (Path.GetExtension(filePath).Equals(".xlsx")) //for 2007 Excel file
sbConnection.Provider = "Microsoft.ACE.OLEDB.12.0";
strExtendedProperties = "Excel 12.0;HDR=Yes;IMEX=1";
sbConnection.Add("Extended Properties", strExtendedProperties);
Nov 24, 2012 12:05 AM|LINK
For Excel or Access connection strings，you can refer to this：
Nov 25, 2012 08:34 AM|LINK
Thanks for the link. I was unaware of site. This site has huge collection of different types of Connections String with their description also.
Nov 25, 2012 08:38 AM|LINK
Thanks for the code. Actually I am also using the code like above.
But my problem is when, User has not installed MS office 2007 or 2010 in System and using Office 365 (2013). In that case it was throwing error. Hoever, I uninstalled Office 2013 and installed Office 2010, Now the same code is working perfect.
By the way, thanks for answers.