nikki23 0 Newbie Poster

This is what I have so far. I need to retrieve data and show in a grid view supplier ID supplier name
and a command field to click more details that will include more detailed info. I am have problems on how to get the rows. i need to retrieve the rows into suppliers

Imports System.data
Imports System.data.OleDb
Imports System.Configuration
Partial Class supplier
Inherits System.Web.UI.Page
Dim ConnString As String = ConfigurationManager.AppSettings("ConnString")
Dim dbPath As String = ConfigurationManager.AppSettings("PathDB")

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
getsuppliers()
dgsuppliers.DataSource = Session("Supplier")
dgsuppliers.DataBind()
End If
End Sub


Private Sub getsuppliers()

Dim mySQL As String = "select SupplierID, Supplier from Products "
Dim dbConn As New OleDbConnection(ConnString & Server.MapPath(dbPath))
Dim dbCommand As New OleDbCommand(mySQL, dbConn)
Dim dbAdapter As New OleDbDataAdapter(dbCommand)
Dim dsSuppliers As New DataSet


Try
dbConn.Open()
dbAdapter.Fill(dsSuppliers, "Suppliers")
Catch ex As Exception
lblResults.Text = "Error occurred when retrieving data from Table: " & ex.Message
Finally
dbConn.Close()
End Try

dgsuppliers.DataSource = dsSuppliers
dgsuppliers.DataBind()
End Sub


Protected Sub dgsuppliers_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgsuppliers.SelectedIndexChanged
Dim mysql As String = "select SupplierID, Supplier, from Products where SupplierID=" & dgsuppliers.SelectedValue & ""
Dim rowsuppliers As DataRow
Dim dbConn As New OleDbConnection(ConnString & Server.MapPath(dbPath))
Dim dbCommand As New OleDbCommand(mysql, dbConn)
Dim dbAdapter As New OleDbDataAdapter(dbCommand)
Dim dsSuppliers As New DataSet

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.