using datareaders and arrays
Ok so i have a database in MS access of questions and answers, this is going to be a sort of onliune multichoice quiz.
Using webmatrix ive generated this code to bring in the data returning a DataReader.
Function MyQueryMethod() As System.Data.IDataReader
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=C:\Documents an"& _
"d Settings\Jonathan Edwards\My Documents\asp\database.mdb"
Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString)
Dim queryString As String = "SELECT [questions].[Q#], [questions].[File], [questions].[Question], [questions]."& _
"[Answer A], [questions].[Answer B], [questions].[Answer C], [questions].[Correct"& _
" Answer] FROM [questions]"
Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
dbConnection.Open
Dim dataReader As System.Data.IDataReader = dbCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
Return dataReader
Dim reader As SqlDataReader = command.ExecuteReader()
End Function
Now if i want to for instance put "Question" into one TextBox, "answer A", "Answer B" and so on into TextBox's of their own, I thought it best to run the data from datareader into seperate arrays, ie. Questions(), answerA(), answerB() and so on.
Is this a sensible way to do it, and if so how can i run the data into such arrays, this is what ive tried somthing liek this ..
do While dataReader.Read()
IDs(i) = dataReader(0) ' or IDs(i) = dataReader(1).ToString
files(i) = dataReader(1)
questions(i) = dataReader(2)
answera(i) = dataReader(3)
answerb(i) = dataReader(4)
answerb(i) = dataReader(5)
'and so on
i=i+1
loop
obviously all these arrays are declared earlier.
could this be modified to work?, or is this just a hopeless mess?
As you can see im fairly new with asp.net, but its important i get somthing to work.

