Murray Brown
asked on
ASP.net get data from a data connection or GridView
Hi
I am using the following VB code to populate a GridView in ASP.net.
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?
I am using the following VB code to populate a GridView in ASP.net.
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)
Try
'// open the connection
cn.Open()
'// execute the sql statement
Using reader As OleDbDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
' While reader.Read()
'// this loops through all of the returned records
'Response.Write("blah")
'End While
GridView1.DataSource = reader
GridView1.DataBind()
End Using
Catch ex As Exception
Response.Write(ex.Message)
Finally
If cn.State <> ConnectionState.Closed Then
cn.Close()
End If
End Try
End Sub
use the EditItem template to read the modified data .....
ASKER
How do I do that
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks very much