Slipbinary Posted February 1, 2004 Posted February 1, 2004 I was wondering if it was possible and how you would take information from a database and store it in an array or variable. I can currently bind a textbox to the database and all. And I can have it keep changing the position of the database and update the textbox to get the data and send it to an array, but is there anyway I can cut out the this method of throwing to a textbox? I've tried using a datareader but can't seem to get it to work right using the Server Explorer access and all. The only thing I could get to work with the datareader command is reading one row of data. Thank for your time, Slyprid Quote
Moderators Robby Posted February 1, 2004 Moderators Posted February 1, 2004 dr.read will loop the resultset until it reaches the end. While dr.Read 'do stuff here End While Quote Visit...Bassic Software
Slipbinary Posted February 1, 2004 Author Posted February 1, 2004 Yeah i've seen that statement before from searching and tried to impliment it, the only thing is I used this code for the command. Dim MyCommand As New OleDb.OleDbCommand("SELECT * FROM TABLE WHERE ID = 1", OleDbConnection1) Dim MyReader As OleDb.OleDbDataReader = MyCommand.ExecuteReader() The problem I ran into with using the loop, is that it doesn't go through whole table. It only grabs whats on ID = 1 . Obviously from looking problem seems to lie in the SQL statement, but i've also tried to use a for loop and a counter in place of the ID =1 , etc... for i = 0 to 100 Dim MyCommand As New OleDb.OleDbCommand("SELECT * FROM TABLE WHERE ID = '" & i & "'", OleDbConnection1) mycommand.executereader() loop Thanks for your time Slipbinary Quote
Moderators Robby Posted February 1, 2004 Moderators Posted February 1, 2004 Remove the Where clause... then you will get all the records from the table "SELECT * FROM TABLE" Quote Visit...Bassic Software
Slipbinary Posted February 1, 2004 Author Posted February 1, 2004 Thanks that worked Hate when it something small like that, been thinking it was something wrong with the code instead of the SQL. Thanks alot Slipbinary Quote
Moderators Robby Posted February 2, 2004 Moderators Posted February 2, 2004 Well it was your SQL statement that was wrong, when you limit your resultset to "ID = 1" and if this is a primary key you will get back a single record from the database. Quote Visit...Bassic Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.