473,387 Members | 1,536 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,387 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 1951
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.