K Feening
asked on
Vb.net Reading sql server table
Hi Experts
Using while reader.read to get the records from a sql Database table
there are 4 records but using the following I am getting only the first record
Dim sql as String = "Select Description from testfilename"
Dim Count as Integer = 0
Read test File
Do while Reader.read
Dim FieldName as Reader.getstring(count)
count = count + 1
combobox.items.add(fieldna me)
loop
Thanks for the help
Using while reader.read to get the records from a sql Database table
there are 4 records but using the following I am getting only the first record
Dim sql as String = "Select Description from testfilename"
Dim Count as Integer = 0
Read test File
Do while Reader.read
Dim FieldName as Reader.getstring(count)
count = count + 1
combobox.items.add(fieldna
loop
Thanks for the help
Declare the variable FieldName outside the loop
ASKER
Sorry to Guy Hengel Dim FieldName as Reader.getstring(count) was actually
Dim FieldName as String = Reader.getstring(count)
Declaring the variable outside the loop still didn't change the problem
I want all records so I setup the reader as company.datacollector.getr eader(sql1 , Nothing)
as it wouldn't accept .getreader(sql1) it needed .getreader(sql1, Nothing)
Is that causing the single record
Hope this makes sense
Dim FieldName as String = Reader.getstring(count)
Declaring the variable outside the loop still didn't change the problem
I want all records so I setup the reader as company.datacollector.getr
as it wouldn't accept .getreader(sql1) it needed .getreader(sql1, Nothing)
Is that causing the single record
Hope this makes sense
>Reader.getstring(count)
is incorrect if you get 4 records with 1 field;
if you get 1 record with 4 fields, you shall not "loop" on the Reader.Read, but just do a "Read once", and then loop on the field count
in which case the code would be:
is incorrect if you get 4 records with 1 field;
if you get 1 record with 4 fields, you shall not "loop" on the Reader.Read, but just do a "Read once", and then loop on the field count
in which case the code would be:
if Reader.read
do while count < Reader.Columns.Count
Dim FieldName as Reader.getstring(count)
count = count + 1
combobox.items.add(fieldname)
end loop
end if
ASKER
Thanks again
Not 1 record with 4 fields 4 records but only getting return of 1 record
What is the code needed to return all 4 records
The table has an Index and a description I need all 4 descriptions
Not 1 record with 4 fields 4 records but only getting return of 1 record
What is the code needed to return all 4 records
The table has an Index and a description I need all 4 descriptions
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you
I hope to be able to use your help again it was excellent
I hope to be able to use your help again it was excellent
is likely
Dim FieldName as String = Reader.getstring(0)