Go Back   Access World Forums > Apps and Windows > VB.NET

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 11-11-2014, 05:57 AM   #1
VC91
Newly Registered User
 
Join Date: Sep 2014
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
VC91 is on a distinguished road
How do I only get required row into my dataset

Hi,

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("ALFK I")
... 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:
Me.TrainingEmployeesTableAdapter.Fill(Me.TrainingD BDataSet.Employees)

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,
Paul.

VC91 is offline   Reply With Quote
Old 02-03-2019, 10:32 PM   #2
vedika
Newly Registered User
 
Join Date: Jan 2019
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
vedika is on a distinguished road
Re: How do I only get required row into my dataset

You may try this basic code in VB.Net. It worked for me.
Code:
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")
vedika is offline   Reply With Quote
Old 02-04-2019, 01:56 AM   #3
isladogs
Part time moderator
 
isladogs's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 8,913
Thanks: 105
Thanked 2,388 Times in 2,195 Posts
isladogs is a name known to all isladogs is a name known to all isladogs is a name known to all isladogs is a name known to all isladogs is a name known to all isladogs is a name known to all
Re: How do I only get required row into my dataset

@vedika
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

__________________
If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left.

Website links:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Colin
Access 2010 32-bit, Access 2016 32-bit & 64-bit, SQL Server Express 2014, Windows 10,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
isladogs is offline   Reply With Quote
Old 02-04-2019, 02:48 AM   #4
sonic8
Newly Registered User
 
Join Date: Oct 2015
Posts: 175
Thanks: 29
Thanked 50 Times in 48 Posts
sonic8 is on a distinguished road
Re: How do I only get required row into my dataset

Quote:
Originally Posted by isladogs View Post
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!

__________________
New article:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
sonic8 is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting the mode of a dataset nbrooke Queries 2 09-20-2012 01:10 AM
Restructure dataset Gannet Modules & VBA 2 12-11-2009 06:19 PM
VB6 Dataset Equivalent Tanner65 Visual Basic 4 06-14-2008 10:06 AM
Dataset captainlove Forms 2 05-02-2008 12:45 PM
dataset prob brosis Modules & VBA 3 05-09-2007 11:30 AM




All times are GMT -8. The time now is 08:09 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World