[RESOLVED] Can someone please comment this code for better understanding: reader = comm.ExecuteR
SqlCommand comm = new SqlCommand("SELECT * FROM UsrTbl, RelativeTable, IP_Table WHERE RelativeTable.UserID IN (SELECT UserID FROM UsrTbl WHERE UserName = @usrnmeLbl)", conn);
comm.Parameters.AddWithValue("@usrnmeLbl", usrNmeLbl.Text);
SqlDataReader reader = comm.ExecuteReader();
//Check to see if the reader has data(Did the username exist in the database? We must check this
if (reader.Read() != false)
I see that comm is a SqlCommand object with the sql command parameters passed to it. Then I believe reader is a data reader object that is being told to reference something about the comm object. But what is it? Is it a property(ExecuteReader())?
Or is it some kind of object creation method that then creates a new reader object that can act like an indexer.
If someone could point out my misconceptions I would really appreciate it.
Thanks in advance.
Re: Can someone please comment this code for better understanding: reader = comm.ExecuteR
ExecuteReader() is one of the commonly used properties of a sqlCommand like .executeNonQuery() etc are. sqlDataReader is a forward only fast way of reading records from a database.
SqlDataReader reader = comm.ExecuteReader(); is how you assign records from a ado command to a reader then access it methods etc to use the data.
if reader.read
if reader.hasRows
while reader.read
.......text += reader.item("xx")
endwhile
datagrid.datasource = reader()
datagrid.databind
reader.close()
comm.close()
Re: [RESOLVED] Can someone please comment this code for better understanding: reader = comm.ExecuteR