Thursday, March 22, 2012

looping question

SqlConnection1.Open()
GetAllowedDomainsDR = ComGetAllowedDomains.ExecuteReader (CommandBehavior.CloseConnection)
Dim i As Integer = 0
Do
GetAllowedDomainsDR.Read()
sAllowedDomains(i) = GetAllowedDomainsDR.GetValue(0)
Dim s1 As String = sAllowedDomains(i)
i += 1
Loop Until GetAllowedDomainsDR.NextResult = False
SqlConnection1.Close()

'----end code.

I got this peace of code to retrieve all domains in that table. But i only can retrieve the first entry. Normally the nextresult method should advance one line in the database.... or not?

In the database three entries are entered. I used my stored procedure in the query analyzer and there it works. So that is not the problem.

My question is plain and simple? What am I doing wrong?hi,

instead of using the do ... loop, its better you use

While (GetallowedDomainsDR.Read())

do whatever u want here

End While

hope this helps.

0 comments:

Post a Comment