Function getProductDetai ls() As System.data.Dat aSet
Dim connstr As String = "server=(local) ; user id='sa'; password='hello ';
Database='MyDat abase'"
Dim sqlconn As System.Data.Sql Client.SqlConne ction = New
System.Data.Sql Client.SqlConne ction(connstr)
Dim querystr As String = "select * From ProductDetails"
Dim mycommand As System.Data.Sql Client.SqlComma nd = New
System.Data.Sql Client.SqlComma nd(querystr, sqlconn)
Dim dataAdapter As System.Data.Sql Client.SqlDataA dapter = New
System.Data.Sql Client.SqlDataA dapter(mycomman d)
Dim dataset As System.data.Dat aSet = New System.data.Dat aSet
Try
If sqlconn.State = ConnectionState .Closed Then
sqlconn.Open()
End If
dataAdapter.Fil l(dataset, "ProductDetails ")
Return dataset
Catch ex As Exception
Label1.Text = "Error in retrieving Products Details!"
End Try
End Function
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then
ProductDetails. DataSource = getProductDetai ls() (ProductDetails is my Id
of my datagrid)
ProductDetails. DataBind()
End If
End Sub
"gordon" <go**********@o ptusnet.com.auw rote in message
news:44******** *************** @news.optusnet. com.au...
Hi
I have some standard text book type examples of oleDB connections and
routines that populate a list box with data with a query on an Access
database.
What I would like to do is to use a datagrid view instead as the
information in the listbox is very unattractive.
would anyone be kind enough to share some code that can use the result of
the select statement in a datagrid view?
Thansk in advance
doug