主题:大家好,我新学的VB,有个代码有问题,想请教大家一下
代码如下,目的是将数据从VB直接输入进数据库里,但是说字符不匹配,不知道是哪里的问题了,麻烦大家帮我看下
Private Sub Command1_Click()
selectmsg
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub selectmsg()
Dim conn As New ADODB.Connection
Dim strconn As String
Dim rs As New Recordset
strconn = "provider=SQLOLEDB;server=127.0.0.1\SQLExpress;uid=sa;pwd=product;initial catalog=test"
conn.ConnectionString = strconn
conn.Open
rs.Open "select * from Mseihin", conn, adOpenKeyset, adLockPessimistic
rs.AddNew
rs.Fields(SeihinID) = "Text1.Text"
rs.Fields(SeihinMei) = "Text2.Text"
rs.Fields(Seihinbangou) = "Text3.Text"
rs.Fields(SeihinkokyakuID) = "Text4.Text"
rs.Fields(SeihinTanka) = "Text5.Text"
rs.Update
rs.Close
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
End Sub
Private Sub Command1_Click()
selectmsg
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub selectmsg()
Dim conn As New ADODB.Connection
Dim strconn As String
Dim rs As New Recordset
strconn = "provider=SQLOLEDB;server=127.0.0.1\SQLExpress;uid=sa;pwd=product;initial catalog=test"
conn.ConnectionString = strconn
conn.Open
rs.Open "select * from Mseihin", conn, adOpenKeyset, adLockPessimistic
rs.AddNew
rs.Fields(SeihinID) = "Text1.Text"
rs.Fields(SeihinMei) = "Text2.Text"
rs.Fields(Seihinbangou) = "Text3.Text"
rs.Fields(SeihinkokyakuID) = "Text4.Text"
rs.Fields(SeihinTanka) = "Text5.Text"
rs.Update
rs.Close
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
End Sub