Netlink2
asked on
How to create an ado control
Hi, I want to use the following code, but I get an error "SqlConnection is not defined".
Private Sub CopyTable( _
ByVal conn As SqlConnection, _
ByVal sourceTableName As String, _
ByVal targetTableName As String)
If conn.State = ConnectionState.Closed Then
conn.Open()
End If
Dim sqlCmd As New SqlCommand("INSERT TargetTable SELECT * FROM SourceTable", conn)
sqlCmd.ExecuteNonQuery()
End Sub
Private Sub CopyTable( _
ByVal conn As SqlConnection, _
ByVal sourceTableName As String, _
ByVal targetTableName As String)
If conn.State = ConnectionState.Closed Then
conn.Open()
End If
Dim sqlCmd As New SqlCommand("INSERT TargetTable SELECT * FROM SourceTable", conn)
sqlCmd.ExecuteNonQuery()
End Sub
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
I get the exact same message when I tried that code.
"SqlConnection is not defined".
"SqlConnection is not defined".
ASKER
OK, I put
Imports System.Data
Imports System.Data.SqlClient
at the top of the code, now I get a new error
keyword not supported 'provider'
This is using
Dim conn As New SqlConnection("Provider=Mi crosoft.Je t.OLEDB.4. 0;Data Source=C:\Alcis\Mick.mdb")
Imports System.Data
Imports System.Data.SqlClient
at the top of the code, now I get a new error
keyword not supported 'provider'
This is using
Dim conn As New SqlConnection("Provider=Mi
ASKER
Figured that one out too, SqlConnection only works with SQL and doesn't work with Access or DSN.
ASKER