OleDbDataReader

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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!
***************************
 
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.
__________________________________
 
Back
Top