Imports system.dataimports system.data.oledbimports system.Webimports System.Web.ui.pageimports System.Web.httpContextimports System.Web.mail
Public Class czl_db Public Overloads Shared Function czl_gettable (ByVal sqlstr As String) As DataTable Try Dim connstr As New OleDbConnection (conn.connstring) Dim mydataadapter As New OleDbDataAdapter (sqlstr, connstr) Dim mydataset As New DataSet mydataadapter.Fill (mydataset, "table0 ") Httpcontext.current.cache (" mycache ") = mydataset.tables (0) if mydataset.tables (0) .rows.count = 0 THEN
End If connstr.Close () Return mydataset.Tables (0) Catch ex As Exception End Try End Function Public Shared Function format_url () As String If System.Web.HttpContext.Current.Request.ServerVariables ( "QUERY_STRING") = "" Then Return System.Web.HttpContext.Current.Request.ServerVariables ( "URL") & "?" Else Dim mYURL As String = (System.Web.HttpContext.Current.Request.ServerVariables ( "URL") & "?" & System.Web.httpContext.current.Request.ServerVariables ("Query_String"))). Toupper Diml ("Page =") IF L> 0 THEN RETURN (Myurl.Substring (0, L) ELSE RETURN MYURL & "&" END IF END IF End Function
Public Shared Function page_split (ByVal sql As String, ByVal lblcurrentpage As Label, ByVal linkpre As HyperLink, ByVal linknext As HyperLink) As PagedDataSource Try Dim myconnection As New OleDbConnection (conn.connstring) myconnection.Open () 'Dim sql As String = " select * from master "Dim dscommand As New OleDbDataAdapter (sql, myconnection) Dim mydataset As DataSet = New DataSet dscommand.Fill (mydataset," table0 ") 'mydatagrid.DataSource = mydataset.Tables (" table0 "). DefaultView' mydatagrid. DataBind () Dim pds As PagedDataSource = New PagedDataSource pds.DataSource = mydataset.Tables ( "table0"). DefaultView pds.AllowPaging = True pds.PageSize = 10 Dim curpage As Integer If Not (System.Web.HttpContext.Current.Request .QueryString ("Page") I., = convert.toint32 (System.Web.httpContext.current.Request. QueryString ( "page")) Else curpage = 1 End If pds.CurrentPageIndex = curpage - 1 lblcurrentpage.Text = "Pages:" curpage.ToString () "/" pds.PageCount.ToString If Not pds.IsFirstPage Then linkpre.NavigateUrl = format_url () "page =" Convert.ToString (curpage - 1) End If If Not pds.IsLastPage Then linknext.NavigateUrl = format_url () "page =" Convert.ToString (curpage 1 )
Endiff Return PDS Catch EX EX EXCETION END TRYEND FUNCTION
Public Shared Function GetTable (Byval SQL AS String) AS DataTable
Try Dim myconnection As New OleDbConnection (conn.connstring) myconnection.Open () Dim mycommand As New OleDbDataAdapter (sql, myconnection) Dim mydataset As New DataSet mycommand.Fill (mydataset, "table0") HttpContext.Current.Cache ( "mycahe" ) = myDataSet.Tables ("Table0") if mydataset.tables (0) .Rows.count = 0 Then System.Web.httpContext.current.response.write ("Temporarily no record!")
Endiff myconnection.close () return mydataset.tables (0) Catch exception
End Try End Function Public Shared Sub master_update (ByVal master_id As String, ByVal master_name As String, ByVal master_pass As String, ByVal setting As String, ByVal statu As Boolean, ByVal lastime As DateTime) 'Public Shared Sub master_update (ByVal master_id As String, ByVal master_name As String, ByVal master_pass As String, ByVal setting As String, ByVal lastime As DateTime) Dim myconnection As New OleDbConnection (conn.connstring) myconnection.Open () Dim mysql As String = "update master set master_name = @ master_name, master_pass = @ master_pass, setting = @ setting, statu = @ statu, lastime = @ lastime where master_id = "& master_id 'Dim mysql As String =" update master set master_name = @ master_name, master_pass = @ master_pass, setting = @ setting, lastime = @ lastime where master_id = "& master_id Dim mycommand As New OleDbCommand (mysql, myconnection) mycommand.Parameters.Add (" @ master_name ", master_name) mycommand.Parameters.Add (" @ master_pass ", Sys tem.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile (master_pass, "md5")) mycommand.Parameters.Add ( "@ setting", setting) mycommand.Parameters.Add ( "@ statu", statu) mycommand.Parameters.Add ( " @Lastime ", Lastime) MyCommand.executenonQuery () MyConnection.close ()
End Sub Public Shared Sub master_delete (ByVal master_id As String) Dim myconnection As New OleDbConnection (conn.connstring) myconnection.Open () Dim mysql As String = "delete * from master where master_id =" & master_id Dim mycommand As New OleDbCommand (mysql , myconnection) mycommand.ExecuteNonQuery () myconnection.Close () End Sub Public Shared Sub master_delete (ByVal master_id As String, ByVal tablename As String) Dim myconnection As New OleDbConnection (conn.connstring) myconnection.Open () Dim sql As String = "delete * from '" & Tablename & "' Where master_id =" & master_id Dim MyCommand as new oledbcommand (sql, myconnection) MyCommand.executenonQuery () MyConnection.close () end Subend Class