Hi,
I'm using the following VB code from Microsoft web site to import an excel sheet to SQL 2005. If I run it for the first time, there is no error, but no table is created in SQL server. If I run it for second time, it gives me a run-time error: Table 'test' already exists. But this table does not exist. If I change the table name, it runs once and running for second time generates the same error.
Any idea, solution, advice is highly appreciated.
Dim cn As adodb.Connection
Dim strSQL As String
Dim lngRecsAff As Long
Set cn = New adodb.Connection
cn.Open "provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Book1.xls;Extended Properties=""Excel 8.0;HDR=YES"""
strSQL = "SELECT * INTO DSN=mts_test;Uid=mts_test;Pwd=mts_test].test FROM [Sheet1$]"
cn.Execute strSQL, lngRecsAff, adExecuteNoRecords
cn.Close
Set cn = Nothing
I'm using the following VB code from Microsoft web site to import an excel sheet to SQL 2005. If I run it for the first time, there is no error, but no table is created in SQL server. If I run it for second time, it gives me a run-time error: Table 'test' already exists. But this table does not exist. If I change the table name, it runs once and running for second time generates the same error.
Any idea, solution, advice is highly appreciated.
Dim cn As adodb.Connection
Dim strSQL As String
Dim lngRecsAff As Long
Set cn = New adodb.Connection
cn.Open "provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Book1.xls;Extended Properties=""Excel 8.0;HDR=YES"""
strSQL = "SELECT * INTO DSN=mts_test;Uid=mts_test;Pwd=mts_test].test FROM [Sheet1$]"
cn.Execute strSQL, lngRecsAff, adExecuteNoRecords
cn.Close
Set cn = Nothing