添加
Dim conn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.Windows.Forms.Application.StartupPath + "\\temp.mdb"
Dim myconn As New OleDb.OleDbConnection(conn)
Dim myselect As String = "insert into 05(cCode,cname,cbody)values(@cCode,@cname,@cbody)"
myconn.Open()
Dim mycommand As New OleDb.OleDbCommand(myselect, myconn)
mycommand.Parameters.Add(New OleDb.OleDbParameter("@cCode", OleDb.OleDbType.VarChar, 50)).Value =TextBox1.text
mycommand.Parameters.Add(New OleDb.OleDbParameter("@cName", OleDb.OleDbType.VarChar, 50)).Value =TextBox2.text
mycommand.Parameters.Add(New OleDb.OleDbParameter("@cBody", OleDb.OleDbType.VarChar, 50)).Value =TextBox3.text
Try
mycommand.ExecuteNonQuery()
MsgBox("添加成功!", MsgBoxStyle.OkOnly, "提示")
Catch ex As Exception
MsgBox("添加失败!")
End Try
myconn.Close()