While m_reader.Read
If Not m_reader("cname") = "" Then
arryname.Add(m_reader("cname"))
arrymail.Add(m_reader("mail"))
End If
End While
For Each item As String In arryname
Next
i hve the above code in which i am adding the fields 2 array
for retriving the values of each field i will need to execute the for loop twice
how can i retive values of both array items using a single loop
Since you seem to be using a very basic array for both items, you could do this.
Dim item As Integer
For item As Integer = 0 To arryname.Length - 1
'arryname(item)
'arrymail(item)
Next
And to cover any rare situations where the array lengths may end up different
Dim item As Integer
For item As Integer = 0 To arryname.Length - 1
If item < arryname.Length Then
'arryname(item)
End If
If item < arrymail.Length Then
'arrymail(item)
End If
Next
tried using
Dim dictionary As New Dictionary(Of String, String)
Dim m_readersc As SqlDataReader = cmdsc1.ExecuteReader()
While m_readersc.Read
If Not m_readersc(“cname”) = “” Then
dictionary.Add(m_readersc(“cid”), m_readersc(“cname”))
End If
End While
On which line… I assume it is referring to your m_readsc(“cid”) or m_readsc(“cname”) as your current code isn’t trying to read from the Dictionary at this point.