Dim cmd As ADODB.Command
Dim cnn As ADODB.Connection
Dim sql As String
Dim str As String
Set cmd = New ADODB.Command
str = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=c:\1.mdb"
dim cnn as new adodb.connection
cnn.ConnectionString = str
cnn.Open
sql = "Create table new (nn text(10),nian text(5))"
With cmd
.ActiveConnection = cnn
.CommandText = sql
.CommandType = adCmdText
.Execute
End With
Dim cnn As ADODB.Connection
Dim sql As String
Dim str As String
Set cmd = New ADODB.Command
str = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=c:\1.mdb"
dim cnn as new adodb.connection
cnn.ConnectionString = str
cnn.Open
sql = "Create table new (nn text(10),nian text(5))"
With cmd
.ActiveConnection = cnn
.CommandText = sql
.CommandType = adCmdText
.Execute
End With
Set cnn = New ADODB.Connection
Set .ActiveConnection = cnn另外如楼上老兄所言在cnn.ConnectionString = str前面加上这一句:Set cnn = New ADODB.Connection
'Add the Reference of Microsoft ADO 2.x Library
Private Sub Form_Load()
Dim cmd As New ADODB.Command
Dim cnn As New ADODB.Connection
Dim sql As String
Dim str As String
'Set cmd = New ADODB.Command
str = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=c:\CommConfig.mdb"
cnn.ConnectionString = str
cnn.Open
sql = "Create table new (nn text(10),nian text(5))"
With cmd
.ActiveConnection = cnn
.CommandText = sql
.CommandType = adCmdText
.Execute
End With
End Sub
代替Dim cnn As ADODB.Connection
Set cnn =New ADODB.ConnectionDim cmd As New ADODB.Command
代替Dim cmd As ADODB.Command
Set cmd = New ADODB.Command