新思路静态单例模式

Imports MySql.Data.MySqlClient
Imports System.Data

Partial Class Default2
    Inherits System.Web.UI.Page

    Private Shared conn As MySqlConnection = New MySqlConnection("Server=127.0.0.1;Database=mydata;User Id=root;Password=;Character Set=gbk")
    Private Shared comm As MySqlCommand = New MySqlCommand("select * from t_user", conn)
    Private Shared msda As MySqlDataAdapter = New MySqlDataAdapter(comm)
    Private Shared dt As DataTable = New DataTable()

    Protected Sub GridView1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.PreRender
        conn.Open()
        dt.Clear()
        msda.Fill(dt)
        GridView1.DataSource = dt
        GridView1.DataBind()
        conn.Close()
    End Sub

End Class

你可能感兴趣的:(Login,Default,登陆处理)