Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

Solved get data from a data connection or GridView

Posted on 2011-03-23
Medium Priority
Last Modified: 2012-08-13

I am using the following VB code to populate a GridView in
I need the user of my website to be able to use this data. How do I read the data
off the GridView using VB code?
Protected Sub Button_SeeWholeCalendar_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button_SeeWholeCalendar.Click
        '// define a connection to the database
        Dim cs As String = ConfigurationManager.ConnectionStrings("WhatEverNameYouWant").ConnectionString
        cs = cs.Replace("App_Data\GC.accdb", Server.MapPath("App_Data\GC.accdb"))

        Dim cn As New OleDbConnection(cs)

        '// define the sql statement to execute
        Dim cmd As New OleDbCommand("SELECT * FROM [Table1]", cn)


            '// open the connection

            '// execute the sql statement
            Using reader As OleDbDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)

                ' While reader.Read()
                '// this loops through all of the returned records
                'End While

                GridView1.DataSource = reader

            End Using

        Catch ex As Exception

            If cn.State <> ConnectionState.Closed Then
            End If
        End Try
    End Sub

Open in new window

Question by:Murray Brown
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2

Expert Comment

ID: 35197063
use the EditItem template to read the modified data .....

Author Comment

by:Murray Brown
ID: 35197067
How do I do that

Accepted Solution

Muralidharand earned 2000 total points
ID: 35197131

Just add a new GridView to the page and, from its Smart Tag, click the Enable Editing checkbox (see attached imge ). This will add a CommandField to the GridView with an Edit button.

Author Closing Comment

by:Murray Brown
ID: 35197169
thanks very much

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question