连接字符串属性尚未初始化。这是我的代码:
Imports System.Data.OleDb
Imports System.Data
Public Class Main_DB
Dim cnn As OleDbConnection = New OleDbConnection()
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Using cnn = New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=G:\PD\Data.accdb")
Using cmd = New OleDbCommand()
cnn.ConnectionString = cmd.CommandText
If Not cnn.State = ConnectionState.Open Then
cnn.Open()
End If
cnn.Close()
cmd.Connection = cnn
cmd.Connection = cnn
cmd.CommandText = "INSERT INTO [database] ([Name], [Address], [EPF])" & _
"VALUES(" & Me.txtname.Text & ",'" & Me.txtadd.Text & "','" & Me.txtPF.Text & "'cnn)"
cmd.ExecuteNonQuery()
cnn.Close()
End Using
End Using
End Sub
End Class