As a context, I am new to ADO.NET and used David Seppa's “ADO.NET 2.0 Programming” to help me build my knowledge.
I am trying to understand the Dataset object, but I think that I may have completely misunderstood the essence and am looking for guidance.
As an example, I created a very simple combo box to fill in combobox with names in the database ("MyDatabase"). The following code works fine for me:
Private Sub frmEmployee_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strConn, strSQL As String
strConn = "Data Source=.\SQLExpress;Initial Catalog=MyDatabase;Integrated Security=True;"
strSQL = "SELECT LastName, FirstName FROM EmployeeTable"
Dim da As New SqlDataAdapter(strSQL, strConn)
Dim ds As New DataSet()
da.Fill(ds, "AllEmployeesList")
For i As Integer = 0 To ds.Tables("AllEmployeesList").Rows.Count - 1
Dim row As DataRow = ds.Tables("AllEmployeesList").Rows(i)
cbAllEmployeesList.Items.Add(row("LastName") & ", " & row("FirstName"))
Next
End Sub
Now suppose I have a button in my form ("GetAge") that is designed to retrieve the age of the employee selected in the combo box from the "AllEmployeesList" dataset and display it in the text box in the same form.
, , , ? , Load? , ?
, . , , , Dataset . , Load, ?
, , Dataset. - ?
,
Alex