嗨,大家好:有誰能幫我解決這個錯誤嗎?謝謝 錯誤1運算符'&'未爲'String'和'System.Windows.Forms.TextBox'類型定義。 C:\用戶\凱西\應用程序數據\本地\臨時項目\ WindowsApplication1 \ Form1.vb的20 20 WindowsApplication1SQL中的調試錯誤
進口System.Data.OleDb 公共類Form1中 公共連接作爲字符串=「提供者= Microsoft.ACE.OLEDB .12.0;數據源= C:\用戶\凱西\桌面\ generalledger.accdb」 公共康恩作爲新的OleDbConnection
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
conn.ConnectionString = connection
If conn.State = ConnectionState.Closed Then
conn.Open()
MsgBox("Open")
Else
MsgBox("Closed")
End If
End Sub
Private Sub BtnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnAdd.Click
Dim sqlQuery As String
sqlQuery = "insert into voucher(VoucherName, Account_Code, Amount) values ('" & TxtVoucher & "', " & TxtAmount & ", '" & TxtAccount & "')"
Dim sqlcommand As New OleDbCommand
With sqlcommand
.CommandText = sqlQuery
.Connection = conn
.ExecuteNonQuery()
End With
MsgBox("Save")
End Sub
末級
上的代碼沒有變化 –