如何把VB+ACCESS 改为 VB+SQL 代码

sz861011 2008-04-01 07:38:08
详细代码,拜托哪位高手帮忙改改,小弟万分感激
Option Explicit

Private Sub Command1_Click()
Static i As Integer '控制登陆的次数
Dim Username As String
Dim Password As String
i = i + 1
Username = txtUser
Password = txtPassword
'判断用户名是否存在
sql = "select * from 登陆 where 用户名='" & Username & "'"
Set Db = OpenDatabase(App.Path + "\db1.mdb")
Set RS = Db.OpenRecordset(sql)
If RS.EOF = False Then
Username = RS.Fields("用户名")
ElseIf i < 3 Then
MsgBox "无效的用户名", , "系统登陆"
txtUser.SetFocus
SendKeys "{Home}+{end}"
Exit Sub
Else
MsgBox "多次错误登陆,再见!", , "系统登陆"
End
End If
'判断密码是否正确
sql = "select * from 登陆 where 用户名='" & Username & "' and 密码='" & Password & "'"
Set RS = Db.OpenRecordset(sql)
If RS.EOF = False Then
frmPic.Show
Denglu_name = Username
Load MDIForm1
Unload Me
ElseIf i < 3 Then
MsgBox "无效的密码", , "系统登陆"
txtPassword.SetFocus
SendKeys "{Home}+{end}"
Else
MsgBox "多次输入错误,请正确输入!", , "系统登陆"
End
End If

End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Label5_Click()

End Sub
...全文
132 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
knowledge_Is_Life 2008-05-01
  • 打赏
  • 举报
回复
不明LZ在说什么
josephSC 2008-04-20
  • 打赏
  • 举报
回复
都连数据库了,怎么还 Set Db = OpenDatabase(App.Path + "\db1.mdb")
另外这个网址 http://www.connectionstrings.com/ 有连接数据库的代码
iasker 2008-04-08
  • 打赏
  • 举报
回复
过路 温习一下
msn2005 2008-04-08
  • 打赏
  • 举报
回复
顺便学习下
sz861011 2008-04-08
  • 打赏
  • 举报
回复
谢谢2楼的链接
sz861011 2008-04-08
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 bluefox1979 的回复:]
将连接串改为连接SQL数据库的连接类型,就搞定
[/Quote]
那个我已经改完了,你看下我代码这个是一个登陆界面的,需要调用数据库,我想问的是把这段原来连ACCESS的代码改成SQL的
cangwu_lee 2008-04-01
  • 打赏
  • 举报
回复

有一個簡單的示範
http://blog.csdn.net/cangwu_lee/archive/2008/04/01/2242306.aspx

bluefox1979 2008-04-01
  • 打赏
  • 举报
回复
将连接串改为连接SQL数据库的连接类型,就搞定

1,217

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧