VB6数据库简单问题

2024-12-26 14:57:11
推荐回答(1个)
回答1:

一:
Private Sub Command1_click()
Adodc1.CommandType = adCmdText
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=" & App.Path & "\a.mdb"
Adodc1.RecordSource = "select test1,test2,test3 from 表一 where test1='a100'"
Adodc1.Refresh
if Adodc1.Recordset.RecordCount>0 then
text2.text=Adodc1.Recordset.Fields("test2")
text3.text=Adodc1.Recordset.Fields("test3")
else
msgbox("不存在。")
end if
End Sub

二:
Private Sub Command2_click()
dim a() as string,b() as string
a=split(text4.text,vbcrlf)
for i=0 to ubound(a)
b=split(a(i)," ")
Adodc1.Recordset.AddNew
Adodc1.Recordset..Fields("test1")=b(0)
Adodc1.Recordset..Fields("test2")=b(1)
Adodc1.Recordset..Fields("test3")=b(2)
next
Adodc1.Recordset.Update
end sub

三:
dim a as string,b() as string
a="dfgfbnhmjh——hnjgh——bnhg——gh"
b=split(a,"——")
for i=0 to ubound(b)
text1.text=text1.text & b(i) & vbcrlf
next