View Single Post
Old 06-15-2004, 05:50 AM   #1 (permalink)
watherton
Registered User
 
Join Date: Jun 2004
Posts: 2
watherton is on a distinguished road
DataReader empty

ok i have this slight problem that is beginning to wear me down.

I have a method that calls a class, which is supposed to return the method a datareader object. When the class returns to the method though the datareader is empty.

here is the code:

public SqlDataReader AuthenticateUser()
{


SqlDataReader dataReader = null;
Classes.Connection conn = new Connection();

SqlParameter[] prams =
{
conn.MakeInParam("@Username",SqlDbType.Char,10,str Username),
conn.MakeInParam("@Password",SqlDbType.Char,10,str Password),
conn.MakeOutParam("@UserID",SqlDbType.Int,4),
conn.MakeOutParam("@bSuccess",SqlDbType.Bit,1),
conn.MakeOutParam("@dLastLogon",SqlDbType.DateTime ,8)
};

conn.RunProc("sp_CheckLogon",prams, out dataReader)

return datareader

here is the calling method

public void RunProc(string procName, SqlParameter[] prams, out SqlDataReader dataReader)
{
SqlCommand objCMD = CreateCommand(procName, prams);
dataReader = objCMD.ExecuteReader();
}


the orignal code was taken from this website ('http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=3) if that helps.

what i need to happen is access the elements with the datareader and populate my local variables etc, but everytime i create a reader.read() object it just ends up in a continous loop because the datareader is empty.

If i have not made myself clear then please say so - any help would be a massive help.

Cheers

Wayne
watherton is offline   Reply With Quote