I'm currently using .NET version 2003. I want to be able to retrieve records.
How do I do so using the OleDbDataReader? I want to be able to retrieve
records using a selected choice from the combo box. Only when the user has
made the selection does the form display the relevant details to that
selection. Can I have some codes as an example?

RE: OleDbDataReader by NoSpamMgbworld

NoSpamMgbworld
Wed Sep 29 10:03:02 CDT 2004

Something like:

string connString = "your conn string here";
string sql = "SELECT * FROM Table WHERE Col1 = "+col1Value;

OleDbConnection conn = new OleDbConnection(connString);
OleDbCommand cmd = new OleDbCommand(sql, conn);

conn.Open();
DataReader dr = cmd.ExecuteReader();

//Do some stuff with the reader
conn.Close();
conn.Dispose();

VB is slightly different in syntax, the concept is the same. NOTE: col1Value
is the value from the dropdown.

---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************



"Nexus" wrote:

> I'm currently using .NET version 2003. I want to be able to retrieve records.
> How do I do so using the OleDbDataReader? I want to be able to retrieve
> records using a selected choice from the combo box. Only when the user has
> made the selection does the form display the relevant details to that
> selection. Can I have some codes as an example?
>

Re: OleDbDataReader by William

William
Wed Sep 29 14:33:17 CDT 2004

The problem with this approach is that it opens your application to SQL
Injection attacks.
I suggest reading about creating a Command object and providing the value in
a Parameter.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

"Cowboy (Gregory A. Beamer) - MVP" <NoSpamMgbworld@comcast.netNoSpamM> wrote
in message news:FBFBE9F5-4F6A-4510-80A0-5F970A551C6F@microsoft.com...
> Something like:
>
> string connString = "your conn string here";
> string sql = "SELECT * FROM Table WHERE Col1 = "+col1Value;
>
> OleDbConnection conn = new OleDbConnection(connString);
> OleDbCommand cmd = new OleDbCommand(sql, conn);
>
> conn.Open();
> DataReader dr = cmd.ExecuteReader();
>
> //Do some stuff with the reader
> conn.Close();
> conn.Dispose();
>
> VB is slightly different in syntax, the concept is the same. NOTE:
> col1Value
> is the value from the dropdown.
>
> ---
>
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
>
> ***************************
> Think Outside the Box!
> ***************************
>
>
>
> "Nexus" wrote:
>
>> I'm currently using .NET version 2003. I want to be able to retrieve
>> records.
>> How do I do so using the OleDbDataReader? I want to be able to retrieve
>> records using a selected choice from the combo box. Only when the user
>> has
>> made the selection does the form display the relevant details to that
>> selection. Can I have some codes as an example?
>>