求用户登录代码

来源:百度知道 编辑:UC知道 时间:2024/06/04 02:52:58
vb+sql链数据库,在dreamwear里做的网站
不是在VB里做的...

你需要建立一个数据库来保存这些用户信息。
数据库的设计包括两个字段,分别保存用户名和密码。数据库名叫“yusion”
表名叫“user”

写代码之前你需要引用ado 控件
具体的办法是添加部件的对话框中选中
microsoft Active Data ...Object control 这句不是很记得怎么写了。
Private Sub command1_click()
dim conn as new adodb.connection
dim rs as new adodb.recordset
dim str as string
Static logintimes As Integer
dim sql as string
str = App.Path
If Right(str, 1) <> "\" Then
str = str + "\"
End If
str = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=" & str & "\yusion.mdb"
conn.open str
rs.cursorlocation=aduseclient
sql="select * from user where 用户名='" & text1.text & "'"
rs.open sql,conn,adopenkeyset.adlockpessimistic
if rs.recordset.eof and rs.recordset.bof then
msgbox "没有此用户"
else
if trim(text2.text)=rs.fields("密码").velue