代码snipptes下面是正确的吗?

时间:2018-03-28 13:41:48

标签: sql vb6

Dim MyConn As ADODB.connection
Set MyConn = New ADODB.connection
Dim MyRecSet1 As New ADODB.Recordset            

MyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Amber\Desktop\Trackingcustomercalls\Copy of Trackingcustomercalls.mdb"
MyConn.Open
Set MyRecSet1 = MyConn.Execute("INSERT INTO ID_ProjectNo VALUES("txtAddProjectNumber.text","txtAddCustomerName.text","txtAddMachine.text")")
MyRecSet1.Update
MsgBox "The record was added to database", vbCritical, "Succesfull adding"
MyConn.Close

我正在寻找..如何连接数据库并使用VB6插入表中。 检查上述程序是否有效。

1 个答案:

答案 0 :(得分:1)

Set MyRecSet1 = MyConn.Execute("INSERT INTO ID_ProjectNo VALUES('" & txtAddProjectNumber.text & "','" & txtAddCustomerName.text "','" & txtAddMachine.text & "')")