Pr!nce0f4Mb3r
07-19-2006, 04:38 PM
new to .NET
playing around with database usage and taking a basic OleDB example and modifying it to see what I can do with it.
I'm using OleDDbDataReader and ExecuteReader
The change to the basic examples is that I
want on a command line to have user enter any sql statement
and I read it in as a string.
connection is straightforward
OleDBCommand cm = new OleDBCommand(cmString, cn);
OleDbDataReader = QReader
QReader = cm.ExecuteReader
and I use
while (QReader.Read()
{
Console.WriteLine(QReader.GetString(0));
}
If I use sql statements with one select argument things seem to work
select firstname from customers
If I use select * from
I get an error. Seems it doesn't like *
If I use select firstname, lastname, etc...
it will grab and write firstname, but not the rest I specify.
I'm guessing that I need GetString(1) (2) etc..., but I won't know what the
sql statement would be beforehand.
What am I missing?
Thanks
playing around with database usage and taking a basic OleDB example and modifying it to see what I can do with it.
I'm using OleDDbDataReader and ExecuteReader
The change to the basic examples is that I
want on a command line to have user enter any sql statement
and I read it in as a string.
connection is straightforward
OleDBCommand cm = new OleDBCommand(cmString, cn);
OleDbDataReader = QReader
QReader = cm.ExecuteReader
and I use
while (QReader.Read()
{
Console.WriteLine(QReader.GetString(0));
}
If I use sql statements with one select argument things seem to work
select firstname from customers
If I use select * from
I get an error. Seems it doesn't like *
If I use select firstname, lastname, etc...
it will grab and write firstname, but not the rest I specify.
I'm guessing that I need GetString(1) (2) etc..., but I won't know what the
sql statement would be beforehand.
What am I missing?
Thanks