Getting data from a database is easy, and working with data is easier than before. The most important concept to remember is that the DataSet is a data structure separate and distinct from a data store. Although you get data from a database in this example, it doesn't matter where the data comes from; the DataSet will always present a consistent programming model. It is a simple collection of data with relational database characteristics. There is no Load, Open, or Execute on a DataSet because it doesn't know where it gets its data from. This section describes how to use a SqlDataAdapter to get data from a database into a DataSet.
Sample Code (with MsSql)
Dim sConnection As String = "server=(local);uid=sa;pwd=password;database=yourDatabase"
Dim objDataAdapter As New SqlDataAdapter("Select * From tableName", sConnection)
Dim dsResult As New DataSet("Result")
If Not IsNothing(objDataAdapter) Then
' Fill data into dataset
objDataAdapter.Fill(dsResult)
objDataAdapter.Dispose()
End If
' Test by bind data into datagridview control
Me.DataGridView1.DataSource = dsResult.Tables(0)
Source: http://vbnetsample.blogspot.com/2007/10/populate-dataset-from-database.html
c programming download free free programming ebooks how to learn c# how to c# string in c# arrays in c# asp.net hosting asp.net controls asp.net cms asp.net pdf
ليست هناك تعليقات:
إرسال تعليق