Saturday, March 11, 2017

Insert, Update, Delete and Select in Gridview using Single Stored Procedure

Introduction


In this article lets see how to Insert, Update, Delete and Select in Gridview using a Single Stored Procedure.
first create the data table like below
  1. Create table in database.
  2. Create Store Procedure.
  3. Design .aspx page.
  4. Write Code on .aspx.CS pag

Step 1. Create table in Database


Table Name:  emp













Step 2. Create Store Procedure.


































Step 3. Create/design .aspx page























Step 4. C# Code


using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;


public partial class Employees : System.Web.UI.Page
{
    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["mycon"].ConnectionString);
    SqlCommand cmd = new SqlCommand("employees2");
    SqlDataAdapter da = new SqlDataAdapter();
    DataSet ds = new DataSet();
    

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindGrid();
            
        }
    }

    protected void insert_Click(object sender, EventArgs e)
    {
        con.Open();
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Connection = con;
        cmd.Parameters.AddWithValue("@action", "INSERT");
        cmd.Parameters.AddWithValue("@name", txtname.Text);
        cmd.Parameters.AddWithValue("@empaddress", txtaddress.Text);
        cmd.Parameters.AddWithValue("@emailid", txtemailid.Text);
        cmd.Parameters.AddWithValue("@contactno", txtcontactno.Text);
        cmd.Parameters.AddWithValue("@city", txtcity.Text);
        cmd.Parameters.AddWithValue("@country", txtcountry.Text);
        Label7.Text = "inserted";
        cmd.ExecuteNonQuery();
        GridView1.DataSource = ds.Tables["emp"];
        GridView1.DataBind();
        con.Close();
        txtname.Text = "";
        txtaddress.Text = "";
        txtemailid.Text = "";
        txtcontactno.Text = "";
        txtcity.Text = "";
        txtcountry.Text = "";
        
       
    }
    protected void update_Click(object sender, EventArgs e)
    {
        con.Open();
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Connection = con;
        cmd.Parameters.AddWithValue("@action", "Update");
        cmd.Parameters.AddWithValue("@empid", ddid.SelectedItem.Text);
        cmd.Parameters.AddWithValue("@name", txtname.Text);
        cmd.Parameters.AddWithValue("@empaddress", txtaddress.Text);
        cmd.Parameters.AddWithValue("@emailid", txtemailid.Text);
        cmd.Parameters.AddWithValue("@contactno", txtcontactno.Text);
        cmd.Parameters.AddWithValue("@city", txtcity.Text);
        cmd.Parameters.AddWithValue("@country", txtcountry.Text);
        Label7.Text = "Updated";
        cmd.ExecuteNonQuery();
        GridView1.DataSource = ds.Tables["emp"];
        GridView1.DataBind();
        con.Close();
        txtname.Text = "";
        txtaddress.Text = "";
        txtemailid.Text = "";
        txtcontactno.Text = "";
        txtcity.Text = "";
        txtcountry.Text = "";
        ddid.Text = "";
       

    }
    protected void delete_Click(object sender, EventArgs e)
    {
        con.Open();
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Connection = con;
        cmd.Parameters.AddWithValue("@action", "DELETE");
        cmd.Parameters.AddWithValue("@empid", ddid.SelectedItem.Text);
        Label7.Text = "";
        cmd.ExecuteNonQuery();
        GridView1.DataSource = ds.Tables["emp"];
        GridView1.DataBind();
        con.Close();
        txtname.Text = "";
        txtaddress.Text = "";
        txtemailid.Text = "";
        txtcontactno.Text = "";
        txtcity.Text = "";
        txtcountry.Text = "";
        
    }
    protected void Select_Click(object sender, EventArgs e)
    {
        con.Open();
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Connection = con;
        cmd.Parameters.AddWithValue("@action", "SELECT");
        cmd.Parameters.AddWithValue("@empid", ddid.SelectedItem.Text);
        da = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        da.Fill(ds);

       
        txtname.Text = ds.Tables[0].Rows[0]["name"].ToString();
        txtaddress.Text = ds.Tables[0].Rows[0]["empaddress"].ToString();
        txtemailid.Text = ds.Tables[0].Rows[0]["emailid"].ToString();
        txtcontactno.Text = ds.Tables[0].Rows[0]["contactno"].ToString();
        txtcity.Text = ds.Tables[0].Rows[0]["city"].ToString();
        txtcountry.Text = ds.Tables[0].Rows[0]["country"].ToString();
    }
    protected void BindGrid()
    {
        con.Open();
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Connection = con;
        cmd.Parameters.AddWithValue("@action", "SELECT2");
        da = new SqlDataAdapter(cmd);
        da.Fill(ds);
        GridView1.DataSource = ds.Tables["emp"];
        GridView1.DataBind();
    }
}


Output:


































Thank You...

Monday, January 30, 2017

How to create Registration and Login Forn in asp.net using masterpage

Introduction

In this post I will explain how to implement simple login form using asp.net and I will explain how to Check Username and Password Exists in database using masterpage in asp.net .

There are Three steps create Login,Registration and Home Pages.

         1.Create Table in Database.
         2.Design .aspx pages.
         3. Write Code on .aspx.cs page.



Step 1. Create table in Database

Table Name: - useraccount














Query for creating a table












Step 2.1 Create/MasterPage .aspx page























Step 3.1 C# Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class MasterPage : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["username"] != null)
        {
            Label1.Text = Session["username"].ToString();
            LinkButton1.Text = "Log out";
        }
        else
        {
            LinkButton1.Text = "Log in!";
        }
     
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        if (LinkButton1.Text == "Log in!")
        {
            Response.Redirect("Login.aspx");
        }
        else if (LinkButton1.Text == "Log out")
        {
            Session.Clear();
            Session.RemoveAll();
            Response.Redirect("Home.aspx");
         
        }
    }
}

Step 2.2 Create/Home .aspx page























Step 3.2 C# Code


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Home : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["username"] != null)
        {
            Label1.Text = "Wel come";
           
        }
        else
        {
            Label1.Text = "Login First!";
        }
    }

}

Step 2.3 Create/Registration.aspx page






















Step 3.3 C# Code


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

public partial class Registration : System.Web.UI.Page
{
    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["mycon"].ConnectionString);
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("Home.aspx");
    }
    protected void btnsubmit_Click(object sender, EventArgs e)
    {
        con.Open();
        SqlCommand cmd = new SqlCommand();
        cmd.CommandText = "insert into useraccount values(@name,@emailid,@password,@contactno)";
        cmd.Connection = con;
        cmd.Parameters.AddWithValue("@name",TextBox1.Text);
        cmd.Parameters.AddWithValue("@emailid", TextBox2.Text);
        cmd.Parameters.AddWithValue("@password", TextBox3.Text);
        cmd.Parameters.AddWithValue("@contactno", TextBox4.Text);
        cmd.ExecuteNonQuery();
        Session["username"] = TextBox2.Text;
        Response.Redirect("Home.aspx");
    }
    protected void Button1_Click1(object sender, EventArgs e)
    {
        Response.Redirect("Home.aspx");
    }

}

Step 2.4 Create/Login.aspx page






















Step 3.4 C# Code


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

public partial class Login : System.Web.UI.Page
{
    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["mycon"].ConnectionString);
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        Response.Redirect("Registration.aspx");
    }
    protected void btnlogin_Click(object sender, EventArgs e)
    {
        con.Open();
        SqlDataAdapter da = new SqlDataAdapter("select * from useraccount where emailid='"+TextBox1.Text+"' and password='"+TextBox2.Text+"'", con);
        DataSet ds = new DataSet();
        da.Fill(ds);
        int c = ds.Tables[0].Rows.Count;
        if (c > 0)
        {
            Session["username"] = TextBox1.Text;
            TextBox1.Text = "";
            TextBox2.Text = "";
            Response.Redirect("Home.aspx");
        }
   }
    protected void btncancel_Click(object sender, EventArgs e)
    {
        Response.Redirect("Home.aspx");
    }

}



Thank You...

Monday, January 23, 2017

How to Use Session State in asp.net with C#.

Introduction

Here I will explain SessionState in Asp.Net with example using c#.


What is SessionState?

The session state is used to maintain the session of each user throughout the application. Session allows information to be stored in one page and access in another page and support any type of object. In many websites we will see the functionality like once if we login into website they will show username in all the pages for that they will store username in session and they will access that session username in all the pages.

Whenever user enters into website new session id will generate for that user. This session Id will delete when he leave from that application. If he enters again he will get new session Id.

We can check this one with simple example for that create one new website and open Default.aspx  page and write the following  code

Default.aspx


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>


<!DOCTYPE html>


<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <table>
        <tr>
            <td colspan="2" style="text-align:center;"><h3>Session State Data</h3></td>
        </tr>
        <tr>
            <td>Name :</td>
            <td><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td>
        </tr>
        <tr>
            <td>Email ID :</td>
            <td><asp:TextBox ID="TextBox2" runat="server"></asp:TextBox></td>
        </tr>
        <tr>
            <td>Contact No :</td>
            <td><asp:TextBox ID="TextBox3" runat="server"></asp:TextBox></td>
        </tr>
        <tr>
            <td colspan="2" style="text-align:center;">
                <asp:Button ID="btnsend" runat="server" Text="Send" OnClick="btnsend_Click" />
            </td>
        </tr>
    </table>
    </div>
    </form>
</body>
</html>


Screen Shot






















C# Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnsend_Click(object sender, EventArgs e)
    {
        Session["name"] = TextBox1.Text;
        Session["email"] = TextBox2.Text;
        Session["contactno"] = TextBox3.Text;
        Response.Redirect("Default2.aspx");
    }
}

Default2.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div><h1>
    Default2.aspx Page</h1><br /><br />
        Name  : <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><br />
        Email ID :<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label><br />
        Contact No :<asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
    </div>
    </form>
</body>
</html>


Screen Shot























C# Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Label1.Text = Session["name"].ToString();
        Label2.Text = Session["email"].ToString();
        Label3.Text = Session["contactno"].ToString();
    }
}


Output




























Thank You...


Sunday, January 22, 2017

Filter ASP.Net GridView using DropDownList

Introduction


In this article I will explain how to change the appearance of gridview and how to filter gridview records with dropdownlist selection using asp.net.

Here I am explaining how to build a feature similar to Microsoft’s Excel AutoFilter in ASP.Net GridView control. Excel AutoFilter allows user to filter the records using the DropDownList in ASP.Net.

There are three steps to insert, update,delete data into database.

  1. Create table in database.
  2. Design .aspx page.
  3. Write Code on .aspx.CS page.

Step 1. Create table in Database

Table Name: - Student















Query for creating a table











Step 2. Create/design .aspx page

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <table>
        <tr>
            <td>Search Record :</td>
            <td><asp:DropDownList ID="DropDownList1" runat="server" Height="30" Width="100">
                <asp:ListItem>All</asp:ListItem>
                <asp:ListItem>Mca</asp:ListItem>
                <asp:ListItem>Mba</asp:ListItem>
                <asp:ListItem>Bsc</asp:ListItem>
                </asp:DropDownList></td>
            <td>&nbsp;&nbsp; <asp:Button ID="btnsearch" runat="server" Text="Search" Height="30" BackColor="#FF6600" Font-Bold="True" ForeColor="White" BorderStyle="None" OnClick="btnsearch_Click"/></td>
        </tr>
    </table><br />
        Total Record : <asp:Label ID="Label1" runat="server" Text=""></asp:Label><br /><br />
        <asp:GridView ID="GridView1" runat="server" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" AllowPaging="True" OnPageIndexChanging="GridView1_PageIndexChanging">
            <FooterStyle BackColor="White" ForeColor="#000066" />
            <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
            <RowStyle ForeColor="#000066" />
            <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
            <SortedAscendingCellStyle BackColor="#F1F1F1" />
            <SortedAscendingHeaderStyle BackColor="#007DBB" />
            <SortedDescendingCellStyle BackColor="#CAC9C9" />
            <SortedDescendingHeaderStyle BackColor="#00547E" />
        </asp:GridView>
    </div>
    </form>
</body>
</html>

Screen-shot























Step 3. C# Code



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

public partial class _Default : System.Web.UI.Page
{

    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["mycon"].ConnectionString);

    protected void Page_Load(object sender, EventArgs e)
    {
        Bindgrid();
    }
    public void Bindgrid()
    {
        con.Open();
        SqlDataAdapter da = new SqlDataAdapter("select * from student",con);
        DataSet ds = new DataSet();
        da.Fill(ds);
        GridView1.DataSource = ds;
        GridView1.DataBind();
        Label1.Text = ds.Tables[0].Rows.Count.ToString();
        con.Close();
    }
    protected void btnsearch_Click(object sender, EventArgs e)
    {
        if (DropDownList1.Text == "All")
        {
            con.Open();
            SqlDataAdapter da = new SqlDataAdapter("select * from student", con);
            DataSet ds = new DataSet();
            da.Fill(ds);
            GridView1.DataSource = ds;
            GridView1.DataBind();
            Label1.Text = ds.Tables[0].Rows.Count.ToString();
            con.Close();
        }
        else if (DropDownList1.Text == "Mca")
        {
            con.Open();
            SqlDataAdapter da = new SqlDataAdapter("select * from student where cource='"+DropDownList1.Text+"'", con);
            DataSet ds = new DataSet();
            da.Fill(ds);
            GridView1.DataSource = ds;
            GridView1.DataBind();
            Label1.Text = ds.Tables[0].Rows.Count.ToString();
            con.Close();
        }
        else if (DropDownList1.Text == "Mba")
        {
            con.Open();
            SqlDataAdapter da = new SqlDataAdapter("select * from student where cource='" + DropDownList1.Text + "'", con);
            DataSet ds = new DataSet();
            da.Fill(ds);
            GridView1.DataSource = ds;
            GridView1.DataBind();
            Label1.Text = ds.Tables[0].Rows.Count.ToString();
            con.Close();
        }
        else if (DropDownList1.Text == "Bsc")
        {
            con.Open();
            SqlDataAdapter da = new SqlDataAdapter("select * from student where cource='" + DropDownList1.Text + "'", con);
            DataSet ds = new DataSet();
            da.Fill(ds);
            GridView1.DataSource = ds;
            GridView1.DataBind();
            Label1.Text = ds.Tables[0].Rows.Count.ToString();
            con.Close();
        }
     
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        Bindgrid();
    }
}

Explanation:



You are advised to change your SqlConnection string where web.config file

<configuration>

    <system.web>
      <compilation debug="true" targetFramework="4.5" />
      <httpRuntime targetFramework="4.5" />
    </system.web>
  <connectionStrings>
    <add name="mycon" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\KRUNAL\Documents\Blogspot Data\FilterData\App_Data\Database.mdf;Integrated Security=True" providerName="System.data.sqlclient"/>
  </connectionStrings>
</configuration>


Output:








































Thank You...


How to Update, Delete, Search, Insert in GridView in vb.Net Windows Application

Introduction


This article shows how to insert, update and delete and search records in a DataGridView in a vb.net Windows Forms application.There are three steps to insert, Update,Delete and search data into database.
  1. Create table in database.
  2. Design .aspx page.
  3. Write Code on .aspx.CS page

Step 1. Create table in Database


Table Name:  Customer














Query for creating a table











Step 2. Create/design .aspx page























Step 3. C# Code

Imports System.Data
Imports System.Data.SqlClient

Public Class Form1

    Dim con As SqlConnection
    Dim cmd As SqlCommand

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        Me.CustomerTableAdapter.Fill(Me.Database1DataSet.customer)
        bindgrid()

    End Sub
    Public Sub bindgrid()
        Dim con As New SqlConnection("Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\KRUNAL\Documents\Visual Studio 2012\Projects\BloggerData\InsertUpdateDelete\InsertUpdateDelete\Database1.mdf;Integrated Security=True")
        con.Open()
        Dim da As New SqlDataAdapter("select * from customer", con)
        Dim ds As New DataSet()
        da.Fill(ds, "customer")
        DataGridView1.DataSource = ds.Tables("customer")
        con.Close()

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim con As New SqlConnection("Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\KRUNAL\Documents\Visual Studio 2012\Projects\BloggerData\InsertUpdateDelete\InsertUpdateDelete\Database1.mdf;Integrated Security=True")
        Dim cmd As New SqlCommand()
        con.Open()
        cmd.CommandText = "insert into customer values(@firstname,@lastname,@address,@email,@contactno)"
        cmd.Connection = con
        cmd.Parameters.AddWithValue("@firstname", TextBox1.Text)
        cmd.Parameters.AddWithValue("@lastname", TextBox2.Text)
        cmd.Parameters.AddWithValue("@address", TextBox3.Text)
        cmd.Parameters.AddWithValue("@email", TextBox4.Text)
        cmd.Parameters.AddWithValue("@contactno", TextBox5.Text)
        cmd.ExecuteNonQuery()
        MessageBox.Show("Inserted Data...")
        bindgrid()
        Me.CustomerTableAdapter.Fill(Me.Database1DataSet.customer)
        con.Close()
        TextBox1.Clear()
        TextBox2.Clear()
        TextBox3.Clear()
        TextBox4.Clear()
        TextBox5.Clear()

    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim con As New SqlConnection("Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\KRUNAL\Documents\Visual Studio 2012\Projects\BloggerData\InsertUpdateDelete\InsertUpdateDelete\Database1.mdf;Integrated Security=True")
        Dim cmd As New SqlCommand()
        con.Open()
        cmd.CommandText = "update customer set firstname=@firstname,lastname=@lastname,address=@address,emailid=@email,contactno=@contactno where id='" + ComboBox1.Text + "'"

        cmd.Connection = con
        cmd.Parameters.AddWithValue("@firstname", TextBox1.Text)
        cmd.Parameters.AddWithValue("@lastname", TextBox2.Text)
        cmd.Parameters.AddWithValue("@address", TextBox3.Text)
        cmd.Parameters.AddWithValue("@email", TextBox4.Text)
        cmd.Parameters.AddWithValue("@contactno", TextBox5.Text)
        cmd.ExecuteNonQuery()
        MessageBox.Show("Updated  Data...")
        bindgrid()
        Me.CustomerTableAdapter.Fill(Me.Database1DataSet.customer)
        con.Close()
        TextBox1.Clear()
        TextBox2.Clear()
        TextBox3.Clear()
        TextBox4.Clear()
        TextBox5.Clear()
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Dim con As New SqlConnection("Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\KRUNAL\Documents\Visual Studio 2012\Projects\BloggerData\InsertUpdateDelete\InsertUpdateDelete\Database1.mdf;Integrated Security=True")
        Dim cmd As New SqlCommand()
        con.Open()
        cmd.CommandText = "delete from customer where id='" + ComboBox1.Text + "'"
        cmd.Connection = con
        cmd.ExecuteNonQuery()
        MessageBox.Show("Deleted  Data...")
        bindgrid()
        Me.CustomerTableAdapter.Fill(Me.Database1DataSet.customer)
        con.Close()
       
    End Sub

    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        Dim con As New SqlConnection("Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\KRUNAL\Documents\Visual Studio 2012\Projects\BloggerData\InsertUpdateDelete\InsertUpdateDelete\Database1.mdf;Integrated Security=True")
        con.Open()
        Dim da As New SqlDataAdapter("select * from customer where id='" + ComboBox1.Text + "'", con)
        Dim ds As New DataSet()
        da.Fill(ds, "customer")
        TextBox1.Text = ds.Tables(0).Rows(0)("firstname").ToString()
        TextBox2.Text = ds.Tables(0).Rows(0)("lastname").ToString()
        TextBox3.Text = ds.Tables(0).Rows(0)("address").ToString()
        TextBox4.Text = ds.Tables(0).Rows(0)("emailid").ToString()
        TextBox5.Text = ds.Tables(0).Rows(0)("contactno").ToString()
        con.Close()
    End Sub

End Class
































Thank You...