使用Vb和SQLSERVER2000做一个登陆界面
使用Vb和SQLSERVER2000做一个登陆界面,需要能够注册用户,求高手帮忙,急用!!不需要特别高端,简单实用即可。...
使用Vb和SQLSERVER2000做一个登陆界面,需要能够注册用户,求高手帮忙,急用!!不需要特别高端,简单实用即可。
展开
1个回答
展开全部
vb登陆程序源代码
你可以这样做建一个模块在里面输入下列
Public conn As ADODB.Connection
Sub main()
Set conn = New ADODB.Connection
conn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;" _
+ "User ID=sa;password=sa;Initial Catalog=您的数据库名;Data Source=127.0.0.1"
conn.Open
from1.Show ’登录亮让界面
End Sub
再在登录界面“确定”下写入如下代码:
Private Sub Command1_Click()
If id.Text = "" Then
MsgBox "用户名不能为空!", vbOKOnly + vbInformation, "友情提示"
id.SetFocus
Exit Sub
End If
If password.Text = "" Then
MsgBox "密码不能为空!", vbOKOnly + vbInformation, "友情提示"
password.SetFocus
Exit Sub
End If
Dim strSQl As String
strSQl = "含稿select * from Users where users_name='" & Trim$(id.Text) & "' and password='" & Trim$(password.Text) & "' "
Dim str As New ADODB.Recordset
Set str = New ADODB.Recordset
str.CursorLocation = adUseClient
str.Open strSQl, conn, adOpenStatic, adLockReadOnly
With str
If .State = adStateOpen Then .Close
.Open strSQl
If .EOF Then
Try_times = Try_times + 1
If Try_times >= 3 Then
MsgBox "您已经三次尝试进入本系统,均不成功,系统将自动关闭", vbOKOnly + vbCritical, "警告"
Unload Me
Else
MsgBox "对不起,用户名不存在或密码错误 !", vbOKOnly + vbQuestion, "警告"
id.SetFocus
id.Text = ""
password.Text = ""
End If
Else
Unload Me
Form2.Show ’登录进入的敬老局另一个界面
End If
End With
End Sub
你可以这样做建一个模块在里面输入下列
Public conn As ADODB.Connection
Sub main()
Set conn = New ADODB.Connection
conn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;" _
+ "User ID=sa;password=sa;Initial Catalog=您的数据库名;Data Source=127.0.0.1"
conn.Open
from1.Show ’登录亮让界面
End Sub
再在登录界面“确定”下写入如下代码:
Private Sub Command1_Click()
If id.Text = "" Then
MsgBox "用户名不能为空!", vbOKOnly + vbInformation, "友情提示"
id.SetFocus
Exit Sub
End If
If password.Text = "" Then
MsgBox "密码不能为空!", vbOKOnly + vbInformation, "友情提示"
password.SetFocus
Exit Sub
End If
Dim strSQl As String
strSQl = "含稿select * from Users where users_name='" & Trim$(id.Text) & "' and password='" & Trim$(password.Text) & "' "
Dim str As New ADODB.Recordset
Set str = New ADODB.Recordset
str.CursorLocation = adUseClient
str.Open strSQl, conn, adOpenStatic, adLockReadOnly
With str
If .State = adStateOpen Then .Close
.Open strSQl
If .EOF Then
Try_times = Try_times + 1
If Try_times >= 3 Then
MsgBox "您已经三次尝试进入本系统,均不成功,系统将自动关闭", vbOKOnly + vbCritical, "警告"
Unload Me
Else
MsgBox "对不起,用户名不存在或密码错误 !", vbOKOnly + vbQuestion, "警告"
id.SetFocus
id.Text = ""
password.Text = ""
End If
Else
Unload Me
Form2.Show ’登录进入的敬老局另一个界面
End If
End With
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询