How to bind grid view from SQL database in vb.net?

.................souce code.................

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="vb.aspx.vb" Inherits="vb" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="GridView1" runat="server">
        </asp:GridView>
    </div>
    <asp:Button ID="Button1" runat="server" Text="Button" />
    </form>
</body>
</html>
...........................end source code.................
....................code..behind...............
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System

Partial Class vb

    Inherits System.Web.UI.Page
  

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim con As new SqlConnection
        Dim ds As New DataSet
        Dim da As SqlDataAdapter

        con = New SqlConnection("data source=.;initial catalog=final;integrated security=true;")
        con.Open()
        da = New SqlDataAdapter("select*from emp100", con)
        da.Fill(ds)
        GridView1.DataSource = ds
        GridView1.DataBind()
        con.Close()


    End Sub
End Class
..............end code behind......................
Share:

No comments:

Post a Comment

Sunday, 16 December 2012

How to bind grid view from SQL database in vb.net?

.................souce code.................

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="vb.aspx.vb" Inherits="vb" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="GridView1" runat="server">
        </asp:GridView>
    </div>
    <asp:Button ID="Button1" runat="server" Text="Button" />
    </form>
</body>
</html>
...........................end source code.................
....................code..behind...............
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System

Partial Class vb

    Inherits System.Web.UI.Page
  

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim con As new SqlConnection
        Dim ds As New DataSet
        Dim da As SqlDataAdapter

        con = New SqlConnection("data source=.;initial catalog=final;integrated security=true;")
        con.Open()
        da = New SqlDataAdapter("select*from emp100", con)
        da.Fill(ds)
        GridView1.DataSource = ds
        GridView1.DataBind()
        con.Close()


    End Sub
End Class
..............end code behind......................

No comments:

Post a Comment

Popular

Blog Archive

Total Pageviews

Archive