那个这次我重建了一个数据库和表那个程序这样写通过了Public DataPath As String
Public DataConnectString As StringPrivate Sub Form_Load()DataPath = App.Path + "\db2.mdb"
DataConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + DataPath + ";Persist Security Info=False" + ";Jet OLEDB:Database Password="Adodc1.ConnectionString = DataConnectStringEnd SubPrivate Sub Command1_Click()
On Error Resume Next
Dim MPassword As String Adodc1.RecordSource = "select * from wht where name='" & Text1.Text & "'"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
MPassword = Adodc1.Recordset.Fields("password")
If Text1.Text = MPassword Then
Form2.Show Unload Me
Else
MsgBox "密码不正确,请您确认后重新输入", , "界面管理登陆"
Text2.Text = ""
Text2.SetFocus
End If
Else
MsgBox "对不起 没有此用户的信息", , "界面管理登陆"
Text1.Text = ""
Text2.Text = ""
End If
End Sub
运行没有问题但是我像把那个前面的那个加载数据库的那个写在Module1.bas上 能够被这个工程的所有form调用 怎么就不行了呢
Public DataConnectString As StringPrivate Sub Form_Load()DataPath = App.Path + "\db2.mdb"
DataConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + DataPath + ";Persist Security Info=False" + ";Jet OLEDB:Database Password="Adodc1.ConnectionString = DataConnectStringEnd SubPrivate Sub Command1_Click()
On Error Resume Next
Dim MPassword As String Adodc1.RecordSource = "select * from wht where name='" & Text1.Text & "'"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
MPassword = Adodc1.Recordset.Fields("password")
If Text1.Text = MPassword Then
Form2.Show Unload Me
Else
MsgBox "密码不正确,请您确认后重新输入", , "界面管理登陆"
Text2.Text = ""
Text2.SetFocus
End If
Else
MsgBox "对不起 没有此用户的信息", , "界面管理登陆"
Text1.Text = ""
Text2.Text = ""
End If
End Sub
运行没有问题但是我像把那个前面的那个加载数据库的那个写在Module1.bas上 能够被这个工程的所有form调用 怎么就不行了呢
解决方案 »
- 新人,找段源码(重新开贴)
- 认真设想一下再回答
- 在VBS中如何使用ProfileString来读取INI文件呢?
- 如何将 Treeview 中 指定的节点展开
- VB中如何通过代码将一个控件从一个容器中移到另一个容器中???
- 求助CreateMutex函数与WaitForSingleObject函数、LPSECURITY_ATTRIBUTES属性的技术资料!
- 急救!!有关listview控件的滚动条的使用方法???
- 58分,谁要!!
- mdac_typ.exe这个文件干吗用的?
- 有谁知道如何编写sqlserver 7.0 Internet客户端
- VB子窗体
- 100分请教:ActiveX控件问题请教,自定义方法问题请教
Public DataConnectString As String
Public Sub Main()
DataPath = App.Path + "\db2.mdb"
DataConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + DataPath + ";Persist Security Info=False" + ";Jet OLEDB:Database Password=prowind"
adoCon.Open (DataConnectString)
Form1.Show
End Sub那个form1是个登陆窗口
代码如下Private Sub Command1_Click()
On Error Resume Next
Dim MPassword As String
Adodc1.ConnectionString = DataConnectString
Adodc1.RecordSource = "select * from wht where name='" & Text1.Text & "'"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
MPassword = Adodc1.Recordset.Fields("password")
If Text1.Text = MPassword Then
Form2.Show Unload Me
Else
MsgBox "密码不正确,请您确认后重新输入", , "界面管理登陆"
Text2.Text = ""
Text2.SetFocus
End If
Else
MsgBox "对不起 没有此用户的信息", , "界面管理登陆"
Text1.Text = ""
Text2.Text = ""
End If
End Sub
怎么这样改写后 运行 出现那个 未发现数据库名称并且没制定默认的驱动程序请问这个如何改写啊 谢谢