RESERVATION – DISCONNECTED DATA ACCESS, ASP.Net

Step 1: Open SQLSERVER 2005 and create a table.
Step 2: Design the webpage for reservation with required controls and a grid view control.
Step 3: On the Button click event on view Button write the code for viewing the data.
Step 4: Establishing the connection using connection string.
Step 5: Create an object  for sql Command sqldataAdapter and Dataset.
Step 6: Set the data source of Gridview as dataset object.
Step 7: Run the program in browser.

PROGRAM
VB CODE
Imports System.Data
Imports System.Web.Configuration
Imports System.Data.SqlClient
Partial Class confirm
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim con As New SqlConnection(WebConfigurationManager.ConnectionStrings("kumaran").ConnectionString)
        Dim qury As String
        qury = "SELECT * FROM booking where uname='" & Session("uname") & "'"
        Dim mycmd As New SqlCommand(qury, con)
        Dim myad As New SqlDataAdapter(mycmd)
        Dim mydataset As New DataSet()
        Try
            con.Open()
            myad.Fill(mydataset, "booking")

            ' Me.GridView1.DataSource = mydataset.Tables("booking")
            For Each row As DataRow In mydataset.Tables("booking").Rows
                Me.Label12.Text = row(0).ToString
                Me.Label5.Text = row(1).ToString
                Me.Label7.Text = row(11).ToString
                Me.Label14.Text = row(12).ToString
                Me.Label15.Text = row(13).ToString
                Me.Label9.Text = row(6).ToString
                Me.Label10.Text = row(4).ToString
                Me.Label16.Text = row(8).ToString
                Me.Label11.Text = row(9).ToString
                Me.Label8.Text = row(3).ToString
                Me.Label18.Text = row(2).ToString

            Next
            ' Me.GridView1.DataBind()
            con.Close()
        Catch ex As Exception
        End Try
        con.Open()


    End Sub


0 comments: