469,356 Members | 2,459 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,356 developers. It's quick & easy.

"SELECT" help needed with DataSets

The code below creates a dataset containing a table
called "Customers" from the Northwind database
Later on in my code, after the database connection is
closed, I need to access this dataset to get all
records with "ContactTitle" = 'Owner' and "City"
= 'London'.

I have tried using the SELECT and Find methods of dataset
techbnology but I can't make them work with multi-
criteria queries.Help!
Bill

P.S. This is strictly a data import problem. I have no
datagrid controls to "bind" the records to. I need the
records back in a "loop-friendly" structure where I can
access them one by one.
Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click

' Open a connection to the database.
Dim strConnection As String = _
"Data Source=localhost; Initial
Catalog=Northwind;" _
& "Integrated Security=True"

Dim cn As SqlConnection = New SqlConnection(strConnection)
cn.Open()

' Set up a data set command object.
Dim strSelect As String = "SELECT * FROM Customers"
Dim dscmd As New SqlDataAdapter(strSelect, cn)

' Load data set.
Dim ds As New DataSet
dscmd.Fill(ds, "Customers")
' Close the connection.
cn.Close()

' Get all records in dataset matching ContactTitle, City
criteria.

' How can i do this?

' For testing purposes display neames using
' Console.Writeline

What's next??
End Sub

Nov 20 '05 #1
4 1197
You need the WHERE clause for example.

SELECT * FROM Customers WHERE City="London"
Tip: In Microsoft Access, build a query and then choose the View\SQL menu
option to see the SQL behind the query, you can copy and paste that into
your ADO.NET/VB.NET application.

Regards -OHM
bill salkin wrote:
The code below creates a dataset containing a table
called "Customers" from the Northwind database
Later on in my code, after the database connection is
closed, I need to access this dataset to get all
records with "ContactTitle" = 'Owner' and "City"
= 'London'.

I have tried using the SELECT and Find methods of dataset
techbnology but I can't make them work with multi-
criteria queries.Help!
Bill

P.S. This is strictly a data import problem. I have no
datagrid controls to "bind" the records to. I need the
records back in a "loop-friendly" structure where I can
access them one by one.
Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click

' Open a connection to the database.
Dim strConnection As String = _
"Data Source=localhost; Initial
Catalog=Northwind;" _
& "Integrated Security=True"

Dim cn As SqlConnection = New SqlConnection(strConnection)
cn.Open()

' Set up a data set command object.
Dim strSelect As String = "SELECT * FROM Customers"
Dim dscmd As New SqlDataAdapter(strSelect, cn)

' Load data set.
Dim ds As New DataSet
dscmd.Fill(ds, "Customers")
' Close the connection.
cn.Close()

' Get all records in dataset matching ContactTitle, City
criteria.

' How can i do this?

' For testing purposes display neames using
' Console.Writeline

What's next??
End Sub


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com
Nov 20 '05 #2
Bill, OHM means :)

SELECT * FROM Customers WHERE City='London'

"One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in message
news:OK**************@TK2MSFTNGP09.phx.gbl...
You need the WHERE clause for example.

SELECT * FROM Customers WHERE City="London"
Tip: In Microsoft Access, build a query and then choose the View\SQL menu
option to see the SQL behind the query, you can copy and paste that into
your ADO.NET/VB.NET application.

Regards -OHM
bill salkin wrote:
The code below creates a dataset containing a table
called "Customers" from the Northwind database
Later on in my code, after the database connection is
closed, I need to access this dataset to get all
records with "ContactTitle" = 'Owner' and "City"
= 'London'.

I have tried using the SELECT and Find methods of dataset
techbnology but I can't make them work with multi-
criteria queries.Help!
Bill

P.S. This is strictly a data import problem. I have no
datagrid controls to "bind" the records to. I need the
records back in a "loop-friendly" structure where I can
access them one by one.
Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click

' Open a connection to the database.
Dim strConnection As String = _
"Data Source=localhost; Initial
Catalog=Northwind;" _
& "Integrated Security=True"

Dim cn As SqlConnection = New SqlConnection(strConnection)
cn.Open()

' Set up a data set command object.
Dim strSelect As String = "SELECT * FROM Customers"
Dim dscmd As New SqlDataAdapter(strSelect, cn)

' Load data set.
Dim ds As New DataSet
dscmd.Fill(ds, "Customers")
' Close the connection.
cn.Close()

' Get all records in dataset matching ContactTitle, City
criteria.

' How can i do this?

' For testing purposes display neames using
' Console.Writeline

What's next??
End Sub


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com

Nov 20 '05 #3
Picky, very Picky, but acknowledged.

Regards - OHM

-------------------------------

Hexathioorthooxalate wrote:
Bill, OHM means :)

SELECT * FROM Customers WHERE City='London'

"One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in
message news:OK**************@TK2MSFTNGP09.phx.gbl...
You need the WHERE clause for example.

SELECT * FROM Customers WHERE City="London"
Tip: In Microsoft Access, build a query and then choose the View\SQL
menu option to see the SQL behind the query, you can copy and paste
that into your ADO.NET/VB.NET application.

Regards -OHM
bill salkin wrote:
The code below creates a dataset containing a table
called "Customers" from the Northwind database
Later on in my code, after the database connection is
closed, I need to access this dataset to get all
records with "ContactTitle" = 'Owner' and "City"
= 'London'.

I have tried using the SELECT and Find methods of dataset
techbnology but I can't make them work with multi-
criteria queries.Help!
Bill

P.S. This is strictly a data import problem. I have no
datagrid controls to "bind" the records to. I need the
records back in a "loop-friendly" structure where I can
access them one by one.
Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click

' Open a connection to the database.
Dim strConnection As String = _
"Data Source=localhost; Initial
Catalog=Northwind;" _
& "Integrated Security=True"

Dim cn As SqlConnection = New SqlConnection(strConnection)
cn.Open()

' Set up a data set command object.
Dim strSelect As String = "SELECT * FROM Customers"
Dim dscmd As New SqlDataAdapter(strSelect, cn)

' Load data set.
Dim ds As New DataSet
dscmd.Fill(ds, "Customers")
' Close the connection.
cn.Close()

' Get all records in dataset matching ContactTitle, City
criteria.

' How can i do this?

' For testing purposes display neames using
' Console.Writeline

What's next??
End Sub


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com


--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com
Nov 20 '05 #4
* "bill salkin" <an*******@discussions.microsoft.com> scripsit:
I have tried using the SELECT and Find methods of dataset
techbnology but I can't make them work with multi-
criteria queries.


Maybe this group is more related to the topic of your question:

<news://msnews.microsoft.com/microsoft.public.dotnet.framework.adonet>

Web interface:

<http://msdn.microsoft.com/newsgroups/default.asp?url=/newsgroups/loadframes.asp?icp=msdn&slcid=us&newsgroup=microso ft.public.dotnet.framework.adonet>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

23 posts views Thread by ian justice | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.