473,406 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

query to add to a listbox

I am trying to add results of a query to a listbox. I have it working when
the query returns one record but I need more. I am used to working with
recordsets but I'm lost here in .net.

This is what I have but the query will return 2 SerialNumbers

Dim str As String

Me.OracleCommand1.CommandText = "SELECT SerialNumber FROM TAB_TEST
WHERE (ACTIVE = 'Y')"

Dim RS As Data.DataColumnCollection
str = OracleCommand1.ExecuteScalar
Me.cmbBox.Items.Add(str)
Nov 22 '05 #1
6 1952
You need to use a DataReader which works a little like a recordset.

This is C#, but hopefully you should get the gist...

OleDbDataReader dr = OracleCommand1.ExecuteReader();
while (dr.Read());
{
me.cmbBox.Items.Add(dr[0].ToString());
}
dr.Close();

Cheers,

Chris.

"Mike D" <Mi***@discussions.microsoft.com> wrote in message
news:0C**********************************@microsof t.com...
I am trying to add results of a query to a listbox. I have it working when the query returns one record but I need more. I am used to working with
recordsets but I'm lost here in .net.

This is what I have but the query will return 2 SerialNumbers

Dim str As String

Me.OracleCommand1.CommandText = "SELECT SerialNumber FROM TAB_TEST
WHERE (ACTIVE = 'Y')"

Dim RS As Data.DataColumnCollection
str = OracleCommand1.ExecuteScalar
Me.cmbBox.Items.Add(str)

Nov 22 '05 #2
You need to use a DataReader which works a little like a recordset.

This is C#, but hopefully you should get the gist...

OleDbDataReader dr = OracleCommand1.ExecuteReader();
while (dr.Read());
{
me.cmbBox.Items.Add(dr[0].ToString());
}
dr.Close();

Cheers,

Chris.

"Mike D" <Mi***@discussions.microsoft.com> wrote in message
news:0C**********************************@microsof t.com...
I am trying to add results of a query to a listbox. I have it working when the query returns one record but I need more. I am used to working with
recordsets but I'm lost here in .net.

This is what I have but the query will return 2 SerialNumbers

Dim str As String

Me.OracleCommand1.CommandText = "SELECT SerialNumber FROM TAB_TEST
WHERE (ACTIVE = 'Y')"

Dim RS As Data.DataColumnCollection
str = OracleCommand1.ExecuteScalar
Me.cmbBox.Items.Add(str)

Nov 22 '05 #3
Thanks for the reply. I get the gist just not the syntax.

If I add

Dim myReader As OracleDataReader = OracleCommand1.ExecuteReader()

I get a:
Type 'OracleDataReader' is not defined error??

Mike

"Chris Mayers" wrote:
You need to use a DataReader which works a little like a recordset.

This is C#, but hopefully you should get the gist...

OleDbDataReader dr = OracleCommand1.ExecuteReader();
while (dr.Read());
{
me.cmbBox.Items.Add(dr[0].ToString());
}
dr.Close();

Cheers,

Chris.

"Mike D" <Mi***@discussions.microsoft.com> wrote in message
news:0C**********************************@microsof t.com...
I am trying to add results of a query to a listbox. I have it working

when
the query returns one record but I need more. I am used to working with
recordsets but I'm lost here in .net.

This is what I have but the query will return 2 SerialNumbers

Dim str As String

Me.OracleCommand1.CommandText = "SELECT SerialNumber FROM TAB_TEST
WHERE (ACTIVE = 'Y')"

Dim RS As Data.DataColumnCollection
str = OracleCommand1.ExecuteScalar
Me.cmbBox.Items.Add(str)


Nov 22 '05 #4
Thanks for the reply. I get the gist just not the syntax.

If I add

Dim myReader As OracleDataReader = OracleCommand1.ExecuteReader()

I get a:
Type 'OracleDataReader' is not defined error??

Mike

"Chris Mayers" wrote:
You need to use a DataReader which works a little like a recordset.

This is C#, but hopefully you should get the gist...

OleDbDataReader dr = OracleCommand1.ExecuteReader();
while (dr.Read());
{
me.cmbBox.Items.Add(dr[0].ToString());
}
dr.Close();

Cheers,

Chris.

"Mike D" <Mi***@discussions.microsoft.com> wrote in message
news:0C**********************************@microsof t.com...
I am trying to add results of a query to a listbox. I have it working

when
the query returns one record but I need more. I am used to working with
recordsets but I'm lost here in .net.

This is what I have but the query will return 2 SerialNumbers

Dim str As String

Me.OracleCommand1.CommandText = "SELECT SerialNumber FROM TAB_TEST
WHERE (ACTIVE = 'Y')"

Dim RS As Data.DataColumnCollection
str = OracleCommand1.ExecuteScalar
Me.cmbBox.Items.Add(str)


Nov 22 '05 #5
Got it.

Thanks for the help
Mike

"Chris Mayers" wrote:
You need to use a DataReader which works a little like a recordset.

This is C#, but hopefully you should get the gist...

OleDbDataReader dr = OracleCommand1.ExecuteReader();
while (dr.Read());
{
me.cmbBox.Items.Add(dr[0].ToString());
}
dr.Close();

Cheers,

Chris.

"Mike D" <Mi***@discussions.microsoft.com> wrote in message
news:0C**********************************@microsof t.com...
I am trying to add results of a query to a listbox. I have it working

when
the query returns one record but I need more. I am used to working with
recordsets but I'm lost here in .net.

This is what I have but the query will return 2 SerialNumbers

Dim str As String

Me.OracleCommand1.CommandText = "SELECT SerialNumber FROM TAB_TEST
WHERE (ACTIVE = 'Y')"

Dim RS As Data.DataColumnCollection
str = OracleCommand1.ExecuteScalar
Me.cmbBox.Items.Add(str)


Nov 22 '05 #6
Got it.

Thanks for the help
Mike

"Chris Mayers" wrote:
You need to use a DataReader which works a little like a recordset.

This is C#, but hopefully you should get the gist...

OleDbDataReader dr = OracleCommand1.ExecuteReader();
while (dr.Read());
{
me.cmbBox.Items.Add(dr[0].ToString());
}
dr.Close();

Cheers,

Chris.

"Mike D" <Mi***@discussions.microsoft.com> wrote in message
news:0C**********************************@microsof t.com...
I am trying to add results of a query to a listbox. I have it working

when
the query returns one record but I need more. I am used to working with
recordsets but I'm lost here in .net.

This is what I have but the query will return 2 SerialNumbers

Dim str As String

Me.OracleCommand1.CommandText = "SELECT SerialNumber FROM TAB_TEST
WHERE (ACTIVE = 'Y')"

Dim RS As Data.DataColumnCollection
str = OracleCommand1.ExecuteScalar
Me.cmbBox.Items.Add(str)


Nov 22 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Giulio | last post by:
Hello, I have a continuous form with a combo box inside. From the combo box I can pick some values which, by the "after-update" event, change some other combo box values determined by a query....
3
by: Sami | last post by:
Maybe I am going about this totally wrong.... What I have written is a query pulling SSN, Student-ID, LastName, FirstName, MiddleInitital from a table. Sort is so LastName, FirstName,...
7
by: Dave Hopper | last post by:
Hi I posted a question recently regarding problems I am having getting a value from a list box to use in a query. I got a lot of help, for which I thank you and it's nearly working! But I need...
4
by: Alan Lane | last post by:
Hello world: I'm including both code and examples of query output. I appologize if that makes this message longer than it should be. Anyway, I need to change the query below into a pivot table...
4
by: carl.barrett | last post by:
Hi, I have a list box that displays 2 columns. Behind it sits a query with five columns. These are Column1 (DOB), column2 (a concatenated string of Surname Forname, Title), Column3 (Surname),...
14
by: Jim Andersen | last post by:
I have a problem with this standard employee-supervisor scenario For pictures: http://www.databasedev.co.uk/self-join_query.html I want to show all employees "belonging" to a specific...
2
by: Chucara | last post by:
Hi, I'm trying to build a simple search in Access. I'll just give a simplified example, as I think I can solve the problem, if you can help me with this subproblem.. I have 2 listboxes -...
2
by: dachrist28 | last post by:
I am trying to populate a listbox with data that is pulled from a sql query. Here is my C# code behind the page: sqlConn1.Open(); SqlCommand sqlComm2 = new SqlCommand("SElECT...
3
by: deejayquai | last post by:
Hello Simple one this I guess, but I'm quite stuck at the moment. I would like to update the records displayed in my listbox (lstStudents) using criteria selected from my combo (cboForm) in a...
20
by: exipnakias | last post by:
Hello Guys. In a form I created a listbox which looks up the values of a table. I want: 1) ..to create a query where a parameter will be needed in order to be loaded. But I do not want to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.