Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Data.OleDb
1 ''关闭连接
2 Sub CloseConn()Sub CloseConn()
3 Conn.Dispose()
4 End Sub
1 Function OpenConn()Function OpenConn()
2 ''连接数据库字符串
3 Dim connStr As String
4 connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
5 & HttpContext.Current.Request.ServerVariables("APPL_PHYSICAL_PATH") _
6 & "App_Data\DataBase.mdb"
7 ''定义数据库连接
8 conn = New OleDbConnection(connStr)
9 conn.Open() ''打开
10 Return False
11 End Function
1 ''此函数获取管理用户登录信息
2 Function MySet()Function MySet()
3 If IsNothing(HttpContext.Current.Request.Cookies("MyInfor")) Then
4 ''未登录的情况
5 HttpContext.Current.Response.Redirect("Default.aspx")
6 Else
7 ''已登录后的情况
8 Dim myCookie As HttpCookie = HttpContext.Current.Request.Cookies("MyInfor")
9 StrAdminName = myCookie("UserName")
10 StrPassword = myCookie("Password")
11 StrLoginTime = myCookie("LoginTime")
12 End If
13 Return False
14 End Function
1 Function IsAdminLogined()Function IsAdminLogined() As Boolean
2 If IsNothing(HttpContext.Current.Request.Cookies("MyInfor")) Then
3 ''未登录的情况
4 IsAdminLogined = False
5 Else
6 '已登录后的情况
7 IsAdminLogined = True
8 End If
9 Return IsAdminLogined
10 End Function
1 Function md5()Function md5(ByVal Str As String) As String
2 md5 = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(Str, "MD5")
3 Return md5
4 End Function
1 Function MySqlDataSource()Function MySqlDataSource(ByVal Sql As String) As DataView
2 Try
3 OpenConn()
4 Dim Da As OleDbDataAdapter
5 Dim Ds As New DataSet
6 ''sql 为传过来的查询语句
7 Da = New OleDbDataAdapter(Sql, conn)
8 Da.Fill(Ds, "temp")
9 CloseConn()
10 MySqlDataSource = Ds.Tables("temp").DefaultView
11 Return MySqlDataSource
12 Catch ex As Exception
13
14 End Try
15 End Function
16
17 Function MySqlExcute()Function MySqlExcute(ByVal Sql As String)
18 OpenConn()
19 Dim cmd As OleDbCommand
20 ''sql 为传过来的查询语句
21 cmd = New OleDbCommand(Sql, conn)
22 cmd.ExecuteNonQuery()
23 CloseConn()
24 Return False
25 End Function
26
Imports System.Data
Imports System.Data.OleDb
1 ''关闭连接
2 Sub CloseConn()Sub CloseConn()
3 Conn.Dispose()
4 End Sub
1
ublic
Class Config
Class Config
2 Public conn As OleDbConnection
3
4 Public StrAdminName As String ''管理用户名
5 Public StrPassword As String ''密码
6 Public StrLoginTime As String ''登录时间
7
2 Public conn As OleDbConnection
3
4 Public StrAdminName As String ''管理用户名
5 Public StrPassword As String ''密码
6 Public StrLoginTime As String ''登录时间
7
1 Function OpenConn()Function OpenConn()
2 ''连接数据库字符串
3 Dim connStr As String
4 connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
5 & HttpContext.Current.Request.ServerVariables("APPL_PHYSICAL_PATH") _
6 & "App_Data\DataBase.mdb"
7 ''定义数据库连接
8 conn = New OleDbConnection(connStr)
9 conn.Open() ''打开
10 Return False
11 End Function
1 ''此函数获取管理用户登录信息
2 Function MySet()Function MySet()
3 If IsNothing(HttpContext.Current.Request.Cookies("MyInfor")) Then
4 ''未登录的情况
5 HttpContext.Current.Response.Redirect("Default.aspx")
6 Else
7 ''已登录后的情况
8 Dim myCookie As HttpCookie = HttpContext.Current.Request.Cookies("MyInfor")
9 StrAdminName = myCookie("UserName")
10 StrPassword = myCookie("Password")
11 StrLoginTime = myCookie("LoginTime")
12 End If
13 Return False
14 End Function
1 Function IsAdminLogined()Function IsAdminLogined() As Boolean
2 If IsNothing(HttpContext.Current.Request.Cookies("MyInfor")) Then
3 ''未登录的情况
4 IsAdminLogined = False
5 Else
6 '已登录后的情况
7 IsAdminLogined = True
8 End If
9 Return IsAdminLogined
10 End Function
1 Function md5()Function md5(ByVal Str As String) As String
2 md5 = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(Str, "MD5")
3 Return md5
4 End Function
VB.NET操作JS代码
1 ''设置警告对话框
2 Function SetAlert()Function SetAlert(ByVal Str As String) As String
3 HttpContext.Current.Response.Write("<script language=""JavaScript"" type=""text/JavaScript"">alert('" & Str & "');</script>")
4 Return False
5 End Function
6
7 ''设置关闭窗口
8 Function SetCloseWindow()Function SetCloseWindow() As String
9 HttpContext.Current.Response.Write("<script language=""JavaScript"" type=""text/JavaScript"">window.close();</script>")
10 Return False
11 End Function
12
13 '地址跳转
14 Function SetLocation()Function SetLocation(ByVal Str As String)
15 HttpContext.Current.Response.Write("<script language=""JavaScript"">" & Chr(13) & " location=""" & Str & """<" & "/" & "script>")
16 Return False
17 End Function
1 ''设置警告对话框
2 Function SetAlert()Function SetAlert(ByVal Str As String) As String
3 HttpContext.Current.Response.Write("<script language=""JavaScript"" type=""text/JavaScript"">alert('" & Str & "');</script>")
4 Return False
5 End Function
6
7 ''设置关闭窗口
8 Function SetCloseWindow()Function SetCloseWindow() As String
9 HttpContext.Current.Response.Write("<script language=""JavaScript"" type=""text/JavaScript"">window.close();</script>")
10 Return False
11 End Function
12
13 '地址跳转
14 Function SetLocation()Function SetLocation(ByVal Str As String)
15 HttpContext.Current.Response.Write("<script language=""JavaScript"">" & Chr(13) & " location=""" & Str & """<" & "/" & "script>")
16 Return False
17 End Function
1 Function MySqlDataSource()Function MySqlDataSource(ByVal Sql As String) As DataView
2 Try
3 OpenConn()
4 Dim Da As OleDbDataAdapter
5 Dim Ds As New DataSet
6 ''sql 为传过来的查询语句
7 Da = New OleDbDataAdapter(Sql, conn)
8 Da.Fill(Ds, "temp")
9 CloseConn()
10 MySqlDataSource = Ds.Tables("temp").DefaultView
11 Return MySqlDataSource
12 Catch ex As Exception
13
14 End Try
15 End Function
16
17 Function MySqlExcute()Function MySqlExcute(ByVal Sql As String)
18 OpenConn()
19 Dim cmd As OleDbCommand
20 ''sql 为传过来的查询语句
21 cmd = New OleDbCommand(Sql, conn)
22 cmd.ExecuteNonQuery()
23 CloseConn()
24 Return False
25 End Function
26
转载于:https://www.cnblogs.com/zhangchenliang/archive/2007/05/07/737500.html