List <user> allusers = new list <user> ();
Sqlconnection conn = new sqlconnection (connection string );
Sqlcommand cmd = new sqlcommand ("SELECT statement", Conn );
Conn. open ();
Using (sqldatareader RDR = cmd. executereader ())
{
While (RDR. Read ())
{
User u = new user ();
User. ID = (INT) RDR ["ID"];
User. loginid = (string) RDR ["loginid"];
User. loginpwd = (string) RDR ["loginpwd"];
User. Name = (string) RDR ["name"];
User. Address = (string) RDR ["Address"];
User. Phone = (string) RDR ["phone"];
User. Mail = (string) RDR ["mail"];
User. userroleid = (INT) RDR ["userroleid"];
User. userstateid = (INT) RDR ["userstateid"];
Allusers. Add (U );
}
}
Conn. Close ();
Return allusers;
========================================================== ====================
Sqlconnection conn = new sqlconnection (connection string );
Sqldataadapter adapter = new sqldataadapter ("SELECT statement", Conn );
Dataset DS = new dataset ();
Adapter. Fill (DS, "table name ");
Return Ds. Tables [0];