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

飞扬跋扈龙少

飞扬跋扈龙少

2016-01-29 17:07

Asp+Sql 对数据库的各种操作,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)



'//添加方法
'//----------------------------(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) & ")" [next]
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(Str
展开更多 50%)
分享

猜你喜欢

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

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

PHP中对数据库操作的封装

PHP
PHP中对数据库操作的封装

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

SQL数据库操作类

编程语言 网络编程
SQL数据库操作类

ASP中使用SQL语句操作数据库

ASP
ASP中使用SQL语句操作数据库

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

用存储过程实现ASP对数据库访问

ASP
用存储过程实现ASP对数据库访问

ASP数据库简单操作教程

ASP
ASP数据库简单操作教程

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

编程爱好者的福音 让IIS6.0支持ASP

编程爱好者的福音 让IIS6.0支持ASP

《仙剑奇侠传5》人物简介:海棠

《仙剑奇侠传5》人物简介:海棠
下拉加载更多内容 ↓