Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

loop dosent work

Status
Not open for further replies.

prasadalone

Programmer
Aug 15, 2002
87
Check below mentioned code output of my following sql query is 2 records but while looping(tobjreader.Read) through it shows only one record please help me


sqlsel="select count(*),membership,sum(amount) from MisData where month(paymrecddate)= " & pmnth & " and year(paymrecddate)=" & curyear & " group by membership "

Bcon.open
bcmd = New SqlCommand(sqlsel, Bcon)
tobjreader = bcmd.ExecuteReader
tobjReader.Read()

If tobjreader.HasRows = true Then
dim val1
dim val2
dim val3
while tobjreader.Read()
val1=tobjreader(1)
val2=tobjreader(0)
val3=tobjreader(2)
response.write("Adding")
response.write("<Br>"
insertdata(val1,val2,val3)
end while
end if


 
Code:
             Bcon.open
             bcmd = New SqlCommand(sqlsel, Bcon)
             tobjreader = bcmd.ExecuteReader
             [b]tobjReader.Read()[/b]
That's because the above line has already read the first row.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top