M
Miro
Im using an OleDb.OleDbDataReader to get some data from an ms access
database.
I am trying to do some things by code to learn to do things without the
wizards and im wondering if there is an easier way to do this.
I created a dataset by code ' super
then i create a table with fields within the dataset 'no prob
then i create a connection and a oledb.oledbcommand and then run this:
Dim rdr As OleDb.OleDbDataReader = cmd.ExecuteReader()
'Debug.WriteLine(curTourneyId)
Dim foundTableColumn As Boolean = False
Do While rdr.Read()
Console.WriteLine("WinID: {0}, PlayerID: {1}, Standing: {2},
GameDate: {3:d}, TourneyID: {4}", _
rdr.GetInt32(0), rdr.GetInt32(1),
rdr.GetInt32(2), rdr.GetDateTime(3), rdr.GetInt32(4))
here is where my question is.
Basically the only way I have found to get my 'data' is by using the
rdr.getIntBLA( position in sql statement ) and assign it to a table column
value.
Example:
Dim GameDate As String = rdr.GetDateTime(3).ToString("d")
is there a different command I shoudl be using instead of the
OLEDBDataReader to do this. It seems to me its kinda 'flimsy' as the
(position in sql statement ) has to be setup and is easily prone to errors.
Im looking for a way to reference the fields directly ....
so basically I call my sql statement...get a list of data - and throw that
data into my datatable in my dataset.
I have it working ( with the above code ) ...but it just doesnt feel like
its the proper way to go about it.
Any suggestions welcome.
Thanks,
Miro
database.
I am trying to do some things by code to learn to do things without the
wizards and im wondering if there is an easier way to do this.
I created a dataset by code ' super
then i create a table with fields within the dataset 'no prob
then i create a connection and a oledb.oledbcommand and then run this:
Dim rdr As OleDb.OleDbDataReader = cmd.ExecuteReader()
'Debug.WriteLine(curTourneyId)
Dim foundTableColumn As Boolean = False
Do While rdr.Read()
Console.WriteLine("WinID: {0}, PlayerID: {1}, Standing: {2},
GameDate: {3:d}, TourneyID: {4}", _
rdr.GetInt32(0), rdr.GetInt32(1),
rdr.GetInt32(2), rdr.GetDateTime(3), rdr.GetInt32(4))
here is where my question is.
Basically the only way I have found to get my 'data' is by using the
rdr.getIntBLA( position in sql statement ) and assign it to a table column
value.
Example:
Dim GameDate As String = rdr.GetDateTime(3).ToString("d")
is there a different command I shoudl be using instead of the
OLEDBDataReader to do this. It seems to me its kinda 'flimsy' as the
(position in sql statement ) has to be setup and is easily prone to errors.
Im looking for a way to reference the fields directly ....
so basically I call my sql statement...get a list of data - and throw that
data into my datatable in my dataset.
I have it working ( with the above code ) ...but it just doesnt feel like
its the proper way to go about it.
Any suggestions welcome.
Thanks,
Miro