欢迎光临
我们一直在努力

Asp+Sql 对数据库的各种操作

建站超值云服务器,限时71元/月

<%

‘//查询方法
‘//—————————-(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)

‘//添加方法
‘//—————————-(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 RsWorkUserInfo.Eof Then
RsWorkUserInfo.AddNew
RsWorkUserInfo("UsersID") = tUserId
RsWorkUserInfo("LoginName") = LoginName
RsWorkUserInfo("UserName") = UserName
RsWorkUserInfo("Password") = Md5(Password)
RsWorkUserInfo.Update
NewRecord = True
Else
NewRecord = False
End if

RsWorkUserInfo.Close
Set RsWorkUserInfo = Nothing

‘//—————————-(2)——————————-
StrSql = "Insert Into Users(UsersId, LoginName, UserName, Password)"
StrSql = StrSql & " Values(" & SqlStr(tUserID) & "," & SqlStr(LoginName) & "," & SqlStr(UserName) & "," & SqlStr(Password) & ")"
Conn.Execute(StrSql)

‘//删除方法
‘//—————————-(1)——————————-
Set RsWorkUserInfo = Server.CreateObject("ADODB.RecordSet")

StrSql = "Delete From Users"
StrSql = StrSql & " Where UsersId=" & SqlStr(tUserID)

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

RsWorkUserInfo.Close
Set RsWorkUserInfo = Nothing

‘//—————————-(2)——————————-
StrSql = "Delete From Users"
StrSql = StrSql & " Where UsersId=" & SqlStr(tUserID)
Conn.Execute(StrSql)

%>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » Asp+Sql 对数据库的各种操作
分享到: 更多 (0)