'在“工程”的“引用”microsoft activex data object2.1 library'在“工程的 ”部件“ microsoft ado data control(6.0)(oledb)
Public cnn As ADODB.Connection '在模块中
Public myword As ADODB.Recordset
Public zt As String
Sub main()
Set cnn = New ADODB.Connection '无密码
cnn.ConnectionString = "driver={Microsoft Access Driver (*.mdb)};" & _
"dbq=" & App.Path & "\word.mdb"
cnn.ConnectionTimeout = 30
cnn.CursorLocation = adUseClient
cnn.Open
Form1.Show
'‘有密码
Set cnn = New ADODB.Connection
cnn.Open "DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=word.MDB;" & _
"DefaultDir=" & App.Path & ";" & _
"UID=admin;PWD=123;"
cnn.CursorLocation = adUseClient
Form1.Show
'**************
cnn1.ConnectionString = "driver={SQL Server};" & _
"server=server;uid=userer;pwd=12345;database=azyw"
'server 为:SqlServer名称
'uid为:Sql用户名
'pwd为:用户口令
'database为:数据库名
cnn1.ConnectionTimeout = 30
cnn1.CursorLocation = adUseClient
cnn1.Open
End Sub
'再窗体中
Private Sub Form_Load()
Set myword = New ADODB.Recordset
myword.Open "select * from wordwendang", cnn, adOpenDynamic, adLockPessimistic
End Sub
Set jzcx = New ADODB.Recordset
If Text1.Text <> "" Then '模糊查询
jzcx.Open "select * from sprk where 入库单号 like '%" & Trim(Text1.Text) & "%'", cnn2, adOpenDynamic, adLockPessimistic
'panduan是 字符型的
jzcx.Open "select * from sprk where 结帐标记='" & panduan & "'", cnn2, adOpenDynamic, adLockPessimistic
'panduan 是数值型的
jzcx.Open "select * from sprk where bh=" & panduan, cnn2, adOpenDynamic, adLockPessimistic
'******************88
上述简单而基本
Public cnn As ADODB.Connection '在模块中
Public myword As ADODB.Recordset
Public zt As String
Sub main()
Set cnn = New ADODB.Connection '无密码
cnn.ConnectionString = "driver={Microsoft Access Driver (*.mdb)};" & _
"dbq=" & App.Path & "\word.mdb"
cnn.ConnectionTimeout = 30
cnn.CursorLocation = adUseClient
cnn.Open
Form1.Show
'‘有密码
Set cnn = New ADODB.Connection
cnn.Open "DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=word.MDB;" & _
"DefaultDir=" & App.Path & ";" & _
"UID=admin;PWD=123;"
cnn.CursorLocation = adUseClient
Form1.Show
'**************
cnn1.ConnectionString = "driver={SQL Server};" & _
"server=server;uid=userer;pwd=12345;database=azyw"
'server 为:SqlServer名称
'uid为:Sql用户名
'pwd为:用户口令
'database为:数据库名
cnn1.ConnectionTimeout = 30
cnn1.CursorLocation = adUseClient
cnn1.Open
End Sub
'再窗体中
Private Sub Form_Load()
Set myword = New ADODB.Recordset
myword.Open "select * from wordwendang", cnn, adOpenDynamic, adLockPessimistic
End Sub
Set jzcx = New ADODB.Recordset
If Text1.Text <> "" Then '模糊查询
jzcx.Open "select * from sprk where 入库单号 like '%" & Trim(Text1.Text) & "%'", cnn2, adOpenDynamic, adLockPessimistic
'panduan是 字符型的
jzcx.Open "select * from sprk where 结帐标记='" & panduan & "'", cnn2, adOpenDynamic, adLockPessimistic
'panduan 是数值型的
jzcx.Open "select * from sprk where bh=" & panduan, cnn2, adOpenDynamic, adLockPessimistic
'******************88
上述简单而基本
Public cnn As ADODB.Connection '在模块中
Public myword As ADODB.Recordset
Public zt As String
Sub main() 再模块中 工程属性该为sub main
Set cnn = New ADODB.Connection '无密码
cnn.ConnectionString = "driver={Microsoft Access Driver (*.mdb)};" & _
"dbq=" & App.Path & "\数据库名.mdb"
cnn.ConnectionTimeout = 30
cnn.CursorLocation = adUseClient
cnn.Open
Form1.Show
end sub
public sub text1.change()
Set myword = New ADODB.Recordset
myword.Open "select * from 表名 where 用户名='"& text1.text &"'", cnn, adOpenDynamic, adLockPessimistic
text1.text的内容等于lewi
text2.text=myword!密码
end sub