hi!
I am trying to create a sql server table from an excel sheet.
Here is the code I have:
'This procedure the xlsx file and dumps it to a table in SQL Server
Private Sub Button5_Click(B yVal sender As System.Object, ByVal e
As System.EventArg s) Handles Button5.Click
'CreateTable()
'GenerateQueryF romDataGridView (DataGridView1, "Spambank",
"temp_spaminfo" )
Dim excelConnection As System.Data.Ole Db.OleDbConnect ion = New
System.Data.Ole Db.OleDbConnect ion("Provider=M icrosoft.Jet.OL EDB.
4.0;Data Source= C:\exporteddata .xlsx;Extended Properties=Exce l
8.0;HDR=YES;")
'Dim sExcelConnectio nString As String =
"Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & (sExcelFileName ) &
";Extended Properties=""Ex cel 8.0;HDR=YES;"""
excelConnection .Open()
Dim excelCommand As New System.Data.Ole Db.OleDbCommand ("SELECT
* INTO [ODBC; Driver={SQL Server};Server= " & lstServers.Sele ctedValue
& ";Database=Spam Bank;Trusted_Co nnection=yes].[temp_spaminfo] FROM
[Sheet1$];", excelConnection )
Dim conn As SqlConnection
Dim cmd As SqlCommand
Dim da As SqlDataAdapter
Dim ds As New DataSet
conn = New SqlConnection(" Data Source=" &
lstServers.Sele ctedValue & ";Initial Catalog=Spamban k;Integrated
Security=SSPI")
cmd = New SqlCommand("SEL ECT * FROM sys.objects WHERE
object_id = OBJECT_ID(N'tem p_spaminfo')", conn)
da = New SqlDataAdapter( cmd)
da.Fill(ds)
If (ds.Tables(0).R ows.Count 0) Then
MessageBox.Show ("Table succesfully created in [" &
lstServers.Sele ctedValue & "].dbo.Spambank")
Else
MessageBox.Show ("The table doesn't exist in Spambank
database")
End If
End Sub
Unfortunately I am getting an error message "Could not find
installable ISAM" at this point
excelConnection .Open()
Your help will be greatly appreciate it.
Thanks
Tammy
I am trying to create a sql server table from an excel sheet.
Here is the code I have:
'This procedure the xlsx file and dumps it to a table in SQL Server
Private Sub Button5_Click(B yVal sender As System.Object, ByVal e
As System.EventArg s) Handles Button5.Click
'CreateTable()
'GenerateQueryF romDataGridView (DataGridView1, "Spambank",
"temp_spaminfo" )
Dim excelConnection As System.Data.Ole Db.OleDbConnect ion = New
System.Data.Ole Db.OleDbConnect ion("Provider=M icrosoft.Jet.OL EDB.
4.0;Data Source= C:\exporteddata .xlsx;Extended Properties=Exce l
8.0;HDR=YES;")
'Dim sExcelConnectio nString As String =
"Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & (sExcelFileName ) &
";Extended Properties=""Ex cel 8.0;HDR=YES;"""
excelConnection .Open()
Dim excelCommand As New System.Data.Ole Db.OleDbCommand ("SELECT
* INTO [ODBC; Driver={SQL Server};Server= " & lstServers.Sele ctedValue
& ";Database=Spam Bank;Trusted_Co nnection=yes].[temp_spaminfo] FROM
[Sheet1$];", excelConnection )
Dim conn As SqlConnection
Dim cmd As SqlCommand
Dim da As SqlDataAdapter
Dim ds As New DataSet
conn = New SqlConnection(" Data Source=" &
lstServers.Sele ctedValue & ";Initial Catalog=Spamban k;Integrated
Security=SSPI")
cmd = New SqlCommand("SEL ECT * FROM sys.objects WHERE
object_id = OBJECT_ID(N'tem p_spaminfo')", conn)
da = New SqlDataAdapter( cmd)
da.Fill(ds)
If (ds.Tables(0).R ows.Count 0) Then
MessageBox.Show ("Table succesfully created in [" &
lstServers.Sele ctedValue & "].dbo.Spambank")
Else
MessageBox.Show ("The table doesn't exist in Spambank
database")
End If
End Sub
Unfortunately I am getting an error message "Could not find
installable ISAM" at this point
excelConnection .Open()
Your help will be greatly appreciate it.
Thanks
Tammy
Comment