ASP + SQL Personal Summary Various Operations for Database

xiaoxiao2021-03-05  25

Relax Life Network (Relaxlife.Net) ASP SQL Personal Summary Various Operations for Database / ************************************** ************************************************

*

* 1, --------- ASP SQL Personal Summary Various Operations for Databases

*

* If you need more code, please:

Http://www.relaxlife.net feels good to help me!

*

*

*********************************************************** ****************** /

<%

'// query method

'//----------------------------(1)---------------- ---------------

SET RSWORKUSERINFO = Server.createObject ("AdoDb.Recordset")

Strsql = "SELECT USERSID, LOGINNAME, Username, Password"

Strsql = strsql & "from users"

Strsql = strsql & "where usersid =" & Sqlstr (TUSERID)

If xi = 1 THEN

Rsworkuserinfo.close

END IF

Rsworkuserinfo.open strsql, conn, 1, 1

IF not rsworkuserinfo.eof kil

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

'//Modification method

'//----------------------------(1)---------------- ---------------

SET RSWORKUSERINFO = Server.createObject ("AdoDb.Recordset")

Strsql = "SELECT USERSID, LOGINNAME, Username, Password" strsql = strsql & "from users"

Strsql = strsql & "where usersid =" & Sqlstr (TUSERID)

If xi = 1 THEN

Rsworkuserinfo.close

END IF

Rsworkuserinfo.open strsql, conn, 1, 3

IF not rsworkuserinfo.eof kil

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 Useers"

Strsql = strsql & "set loginname =" & SQLSTR (Loginname) & ", UserName =" & Sqlstr (username) & ", password =" & sqlstr (password)

Strsql = strsql & "where usersid =" & Sqlstr (TUSERID)

Conn.execute (STRSQL)

'// Add method

'//----------------------------(1)---------------- ---------------

SET RSWORKUSERINFO = Server.createObject ("AdoDb.Recordset")

Strsql = "SELECT USERSID, LOGINNAME, Username, Password"

Strsql = strsql & "from users"

Strsql = strsql & "where usersid =" & Sqlstr (TUSERID)

If xi = 1 THEN

Rsworkuserinfo.close

END IF

Rsworkuserinfo.open strsql, conn, 1, 3

IF rsworkuserinfo.eof the

Rsworkuserinfo.addnew

Rsworkuserinfo ("usersid" = tuserid

Rsworkuserinfo ("Loginname") = loginname

Rsworkuserinfo ("username") = username

RsworkUserInfo ("password") = MD5 (Password)

Rsworkuserinfo.updatenewrecord = 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 (UserName) & "," & Sqlstr (Password) & ")

Conn.execute (STRSQL)

'// Delete method

'//----------------------------(1)---------------- ---------------

SET RSWORKUSERINFO = Server.createObject ("AdoDb.Recordset")

Strsql = "delete from users"

Strsql = strsql & "where usersid =" & Sqlstr (TUSERID)

If xi = 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)

%>

[This post by CEXO255 final edited in 2005-4-9 08:25]

转载请注明原文地址:https://www.9cbs.com/read-35987.html

New Post(0)