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

problem whem importing EXCEL sheet to SQL server

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 :
Expand|Select|Wrap|Line Numbers
  1. Dim excelConnection As System.Data.OleDb.OleDbConnection = New
  2. System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
  3. Source=c:/test.xls;Extended Properties=Excel 8.0;")
  4. excelConnection.Open()
  5.  
  6. Dim excelCommand As New System.Data.oledb.OleDbCommand("INSERT
  7. INTO [OBDC; Driver={SQL
  8. Server};Server=(local);Database=FullDate;Trusted_C onnection=yes].[Population]
  9. SELECT * FROM [Population$];", excelConnection)
  10.  
  11. 'Dim ExcelCommand As New System.Data.OleDb.OleDbCommand("SELECT
  12. INTO [ODBC;Driver={SQL
  13. Server};Server=(local);Database=FullDate;Trusted_C onnectionÂ*=yes].[Population] FROM [Population$];", excelConnection)
  14.  
  15. excelCommand.ExecuteNonQuery()
  16. excelConnection.Close()
.

ALSO i wanted to ask how can i map importing data from the excel sheet to SQL with the primary key. Can anyone give me a syntax

10x in advance
Oct 4 '07 #1
1 1837
If you are searching for an example on how to correct your error "Could not find installable ISAM" you may want to search here: http://support.microsoft.com/kb/209805

If you are searching for an example on how to upload Excel data into SQL Server Table here is how you do it:

Expand|Select|Wrap|Line Numbers
  1. Public Sub ReadDataFromExcelIntoSqlServer() 
  2. Try 
  3. Dim excelConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\RiskAuditor\Sample\Product.xls;Extended Properties=Excel 8.0" 
  4.  
  5. ' Create Connection to Excel Workbook 
  6. Using connection As New OleDbConnection(excelConnectionString) 
  7. Dim command As New OleDbCommand("Select Name,No,Pay,Salary,Total from [Sheet1$]", connection) 
  8. connection.Open() 
  9.  
  10. ' Create DbDataReader to Data Worksheet 
  11. Using dr As OleDbDataReader = command.ExecuteReader() 
  12. ' SQL Server Connection String 
  13. Dim myConnection As New SqlConnection() 
  14. myConnection.ConnectionString = "database=Risk_AuditNew;User ID = sa;Pwd=sa" 
  15. myConnection.Open() 
  16.  
  17. ' Bulk Copy to SQL Server 
  18. Using bulkCopy As New SqlBulkCopy(myConnection) 
  19. bulkCopy.DestinationTableName = "ExcelData" 
  20. bulkCopy.WriteToServer(dr) 
  21. End Using 
  22.  
  23. myConnection.Close() 
  24. End Using 
  25. End Using 
  26. Catch ex As Exception 
  27. Response.Write(ex.Message) 
  28. Finally 
  29. End Try 
  30. End Sub 
  31.  
Example Code was gathered from: http://www.csharphelp.com/board2/rea...=28912&t=28912
and converted into VB.

- Aaron Sandoval
Nov 27 '07 #2

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

Similar topics

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...
2
by: Mr. Bungle | last post by:
When importing excel from access I am fully aware that one can import directly into a table. Can you get as specific via code or something to import data from an excel sheet to a FORM (Not Table)...
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...
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...
4
by: alvinstraight38 | last post by:
Hey guys, I am trying to import data from an Excel spreadsheet into my SQL database. I am running SQL 2005. I following Microsoft's instructions for creating a linked server, and it appeared...
4
by: Harshe | last post by:
hello all, I am trying to code, but i am just stuck after importing one sheet. so here is the gist of what i need help with. In a workbook at the start of the year (january) i will have 4...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.