473,545 Members | 529 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem whem importing EXCEL sheet to SQL server

2 New Member
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 1852
aaronsandoval
13 New Member
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
4022
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 need to input this in an Access database, where I do a comparison with the Actual cost. The table “TblBudget” in Access is made of 4 fields, namely:...
2
4982
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) through a command button. For example: cell C5 on the selected excel spread sheet = textbox2 in the current form. This is for a service repair...
7
3035
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 correct cells within that worksheet. The Excel Book is made up of 12 worksheets named Jan-Dec. Each worksheet has columns labeled as each day of that...
9
3897
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. There is no further explanation. What are the kinds of things that make this happen? Thanks from an obvious rookie. Gordon
1
2294
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 the data from the excel sheet in a datatable in my excel sheet. For this i have used an ODBC connection and selected the contents from my excel...
3
8913
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 application, I would typically not know what the names of the sheets are going to be before I open the Excel file. I am wondering if there is a SELECT...
0
2991
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 HRESULT: 0x800A03EC Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more...
4
2760
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 to work. However when I run this query: SELECT * INTO test FROM OPENQUERY(EFORMS, 'SELECT * FROM ')
4
7341
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 sheets and these sheets will keep increasing to 12 when the month is december. so i want is, sheet 1 (named abc) should go into table 1 (named abc), sheet...
0
7465
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7416
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7752
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5969
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5325
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4944
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3449
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1878
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1013
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.