View Data In Gridview (ASP.Net / VB.Net)


Imports System.Data
Imports System.Data.SqlClient
Public Class show_data
    Inherits System.Web.UI.Page
    Dim cmd As SqlCommand
    Dim cn As New SqlConnection("Data Source=SARIB-ALI\SQLEXPRESS;Initial Catalog=infra;Integrated Security=True")


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        cn.Close()
        cn.Open()
        cmd = New SqlCommand("select* from table_1", cn)
        GridView1.DataSource = cmd.ExecuteReader()
        GridView1.DataBind()
    End Sub
End Class

No comments:

Post a Comment