• ** There has been a recent site upgrade. Please clear your browser cache to avoid issues. **
  • New forum feature - post voting and best solution

    Check out this thread for the details: https://www.access-programmers.co.uk/forums/threads/new-forum-feature-post-voting-and-best-answer.314134/

    This new feature looks great to me! :)

  • We now have 3 forum themes

    Go for the default (light) theme, Shades of Grey or Shades of Blue. I just added the Blue one.

    The thread about it is here: https://www.access-programmers.co.uk/forums/threads/new-forum-theme-shades-of-blue.314136/

How do I only get required row into my dataset (1 Viewer)


New member
Local time
Today, 03:12
Sep 29, 2014

I am fairly new to vb.net but making progress...

I am using Visual Studio 2013 to create VB.net project. I have used the on GUI data sources to get data onto my form but the TableAdapter.Fill is retrieving all rows rather than just the one I want.

Basically Mainform calls SelectEmployeeForm which has a datatable array where the required emp is selected. In the Employee table there is a primary key called ID which I am logging for the selected employee row in a public variable called SelectedEmployeeID
(I am detailing this as I found...
Dim customersRow As NorthwindDataSet.CustomersRow
customersRow = NorthwindDataSet1.Customers.FindByCustomerID("ALFKI")
... on a MSDN page and thought this might be a solution as I have the ID value but could not get it to work. Once I had my customersRow I did not know how to get its data onto my form without doing a series of me.field = statements for each form field, which seemed stupid.

Basically on Mainform I have the autocreated line:

Where this fills my DataSet with all rows I only want the particular one I have the ID for.

Could someone please tell me how I can just load the required row into the me dataset.

I hope that made sense.

Many thanks,


Registered User.
Local time
Today, 08:42
Jan 24, 2019
You may try this basic code in VB.Net. It worked for me.
Dim ds As New DataSet Dim dt As DataTable Dim dr As DataRow Dim cl As DataColumn Dim i As Integer dt = New DataTable() cl = New DataColumn( "theColumn", Type.GetType("System.Int32")) dt.Columns.Add(cl) dr = dt.NewRow() dr("theColumn") = 1 dt.Rows.Add(dr) dr = dt.NewRow() dr("theColumn") = 2 dt.Rows.Add(dr) ds.Tables.Add(dt) For i = 0 To ds.Tables(0).Rows.Count - 1 Console.WriteLine( ds.Tables(0).Rows(i).Item(0).ToString) Next i 
Dim connectionString As String = "Data Source=MUKUNTUWEAP;" & "Initial Catalog=Booze;" & "Integrated Security=True" Dim cn As New SqlConnection(connectionString) Dim commandWrapper As SqlCommand = New SqlCommand("SELECT * FROM RECIPES", cn) Dim dataAdapter As SqlDataAdapter = New SqlDataAdapter Dim myDataSet As DataSet = New DataSet dataAdapter.SelectCommand = commandWrapper dataAdapter.Fill(myDataSet, "Recipes") 
Dim r As DataRow For Each r In myDataSet.Tables("Recipes").Rows Console.WriteLine(r("RecipeName").ToString()) Next 
Dim objCommandBuilder As New SqlCommandBuilder(dataAdapter) dataAdapter.Update(myDataSet, "Recipes")


Local time
Today, 03:12
Jan 14, 2017
Each day for the past week or more, you have replied to an old thread in the rarely used VB.Net forum. After 4+ years or longer in some cases, it is highly unlikely that the OP is still waiting for an answer and in most cases don't appear to be an active AWF member.

This type of behaviour is often used by spammers and is raising suspicions.

If you have useful contributions to make, I suggest you look at areas that are more often used and please focus on current threads for your answers. Otherwise there is a risk that your contributions will be treated as spam and your account may be deleted


Local time
Today, 04:12
Oct 27, 2015
This type of behaviour is often used by spammers and is raising suspicions.
This is the elevenths post and already there appears the suspicious link I was waiting for...

PS: If the coding style shown in that answer is what that dubious "training center" is teaching, I recommend getting training elsewhere!

Users who are viewing this thread

Top Bottom