DataGridView+DataSet+SqlDataAdapter+StoreProc+SqlCommand in 2.0 ASP.NET(VB)

Posted: Thursday,March 12, 2009 in ASP.NET VB
Tags: , , , , , ,

This is the code to show the data from table using store procedure which the toolbox is datagridview in asp.net : 

strConString = System.Configuration.ConfigurationManager.AppSettings(“ConnectionString”)
        conMyData = New SqlConnection(strConString)

        conMyData.Open()

        cmd = New SqlCommand(“spr_lihat_profile”, conMyData)
        cmd.CommandType = CommandType.StoredProcedure

        ‘ Create a billion passing parameters
        cmd.Parameters.Add(New SqlParameter(“@user”, OleDbType.VarChar)).Value = lblUser.Text

        dr = New SqlDataAdapter(cmd)

        Dim ds As New DataSet
        dr.Fill(ds, “datasetprofile”)
        gvProfile.DataSource = ds
        gvProfile.DataBind()

        conMyData.Close()

 

Just declare(with dim…) all of the variable needed..

Have A Nice Try

Good Luck

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s