只需在表单上创建 3 个文本框和 1 个按钮复制所有这些代码,不要忘记相应地命名文本框
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Dim Con As OleDbConnection
Dim cmd As New OleDbCommand
Dim conString As String = "This part you have to do it your self you can go to this link to check whick string works for u http://www.connectionstrings.com/"
Public Sub CourseSave()
Try
Dim con As New OleDbConnection
con.ConnectionString = conString
con.Open()
cmd.Connection = con
cmd.CommandText = "insert into tablename(Name, [Course Name], Address) values('" & Me.txtName.Text & "', '" & Me.txtCourseName.Text & "', '" & Me.txtAddress.Text & "')"
cmd.ExecuteNonQuery()
con.Close()
MsgBox("New Course Saved")
con.Close()
con.Dispose()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
CourseSave()
End Sub
End Class
如果您仍然收到错误,请向我发送错误信息,我可能会为您提供帮助。