Theseekers
Technical User
Hi Tekers,
I am fairly new to ASP.net and have simple question as I am trying to learn ASP.net.
I have a page where user can search for either last name, first name, or both. My ultimate goal is this: if any record found load it up with data from the recordset. If not don't show the grid.
In order to find out the # of record return I have used the code below to get the # of record returned:
This is ok however, if I want to populate my grid with data; I have to make another connection to the database with a different SQLQryStr where I explicitly go after fields that I want to display on the gird. This seem to me is very inefficient and will create lots of trips between client and server.
My question is this. Is there away that i can kill 2 birds with 1 stone meaning get the total of record and at the same time get the wanted fields for the grid?
TIA for your input and suggestion
The seekers is out seeking......
I am fairly new to ASP.net and have simple question as I am trying to learn ASP.net.
I have a page where user can search for either last name, first name, or both. My ultimate goal is this: if any record found load it up with data from the recordset. If not don't show the grid.
In order to find out the # of record return I have used the code below to get the # of record returned:
Code:
Dim SQLQryStr as string = ("Select count(*) from <table name> where fname like '" & Request.Form("TxtFname") & "%'")
DBCommand = New SqlCommand(SQLQryStr, DBConn)
DBConn.Open()
RecCount = CType(DBCommand.ExecuteScalar, Integer)
DBConn.Close()
if (RecCount > 0) then
response.write (reccound & " record(s) found.")
else
response.write ("no record found")
endif
This is ok however, if I want to populate my grid with data; I have to make another connection to the database with a different SQLQryStr where I explicitly go after fields that I want to display on the gird. This seem to me is very inefficient and will create lots of trips between client and server.
My question is this. Is there away that i can kill 2 birds with 1 stone meaning get the total of record and at the same time get the wanted fields for the grid?
TIA for your input and suggestion
The seekers is out seeking......