當前位置: 首頁IT技術(shù) → Asp與Sql構(gòu)建網(wǎng)站系統(tǒng)中對數(shù)據(jù)庫的各種操作的函數(shù)代碼分享

Asp與Sql構(gòu)建網(wǎng)站系統(tǒng)中對數(shù)據(jù)庫的各種操作的函數(shù)代碼分享

更多

本文提供給大家分享的是關(guān)于Asp與Sql構(gòu)建網(wǎng)站系統(tǒng)中對數(shù)據(jù)庫的各種操作的函數(shù)代碼,希望能夠?qū)Υ蠹矣杏谩?/p>

<%
  
  '//查詢方法
  '//----------------------------(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)
  
  %>

熱門評論
最新評論
發(fā)表評論 查看所有評論(0)
昵稱:
表情: 高興 可 汗 我不要 害羞 好 下下下 送花 屎 親親
字數(shù): 0/500 (您的評論需要經(jīng)過審核才能顯示)