新微赢技术网

标题: Asp+Sql对数据库的各种操作 [打印本页]

作者: Bu怕Bu怕    时间: 2009-3-16 16:06
标题: Asp+Sql对数据库的各种操作
<%
'//查询方法
'//----------------------------(1)-------------------------------
Set RsWorkUserInfo = Server.CreateObject("ADODB.RecordSet")

StrSql = "Select UsersId, LoginName, UserName, Password"
StrSql = StrSql & " From Users"
StrSql = StrSql & " Where UsersId=" & SqlStr(tUserID)

If RsWorkUserInfo.State = 1 Then
RsWorkUserInfo.Close
End If
RsWorkUserInfo.Open StrSql,Conn,1,1

If Not RsWorkUserInfo.Eof Then
LoginName = RsWorkUserInfo("LoginName")
UserName = RsWorkUserInfo("UserName")
Password = RsWorkUserInfo("Password")
End if

RsWorkUserInfo.Close
Set RsWorkUserInfo = Nothing

'//----------------------------(2)-------------------------------
StrSql = "Select UsersId, LoginName, UserName, Password"
StrSql = StrSql & " From Users"
StrSql = StrSql & " Where UsersId=" & SqlStr(tUserID)
Set RsFind = Conn.Execute(StrSql)

If Not RsFind.Eof Then
LoginName = RsFind("LoginName")
UserName = RsFind("UserName")
Password = RsFind("Password")
End if

RsFind.Close
Set RsFind = Nothing

'//修改方法
'//----------------------------(1)-------------------------------
Set RsWorkUserInfo = Server.CreateObject("ADODB.RecordSet")

StrSql = "Select UsersId, LoginName, UserName, Password"
StrSql = StrSql & " From Users"
StrSql = StrSql & " Where UsersId=" & SqlStr(tUserID)

If RsWorkUserInfo.State = 1 Then
RsWorkUserInfo.Close
End If
RsWorkUserInfo.Open StrSql,Conn,1,3

IF Not RsWorkUserInfo.Eof Then
RsWorkUserInfo("LoginName") = LoginName
RsWorkUserInfo("UserName") = UserName

RsWorkUserInfo("Password") = Md5(Password)
RsWorkUserInfo.Update
Update = True
Else
Update = False
End if

RsWorkUserInfo.Close
Set RsWorkUserInfo = Nothing

'//----------------------------(2)-------------------------------
StrSql = "Update Users"
StrSql = StrSql & " Set LoginName=" & SqlStr(LoginName) & ", UserName=" & SqlStr(UserName) & ", Password=" & SqlStr(Password)
StrSql = StrSql & " Where UsersId=" & SqlStr(tUserID)
Conn.Execute(StrSql)




欢迎光临 新微赢技术网 (http://bbs.weiying.cn/) Powered by Discuz! X3.2