Cerebrus,
You are right about the grammatical mistake about IsUserHasAccess
method but now I cant do anything as this is not
my project, it is someone who left it in between and being a senior to
him and none was ready to take this project
there was no choice for me,,.
Now back to the main point,,, Okie in above code both snippets are in
one class called SQLConnect,
and the first snippet has been called when you use this component
class I mean when you create a new
object of that class.
Second snippet is (which is that IsUserHasAccess) method, it actually
runs the query and retrieve a
checkpoint (using DataReader.HasRows() method) which says whether the
query returns any row or not
and as if it is,, it means the table (called tblStaff) has user
inserted into it.
Now I have checked the connection state before using EXECUTE READER
if (myConnection.State == ConnectionState.Open)
so ultimately the second code snippet look like this -->
queryStr = "SELECT [PKUserID] FROM tblQuoteUser WITH (NOLOCK) " +
" WHERE [NetworkLoginName] = '" +
sUsername.Trim()
+ "'";
try
{
if (myConnection.State == ConnectionState.Open)
{
_mSqlCmd = new SqlCommand(queryStr, myConnection);
SqlDataReader tDReader2 = _mSqlCmd.ExecuteReader();
if (tDReader2.HasRows)
{
retVal = true; // Record Exists having same User Name
}
else
{
erString = "User Does not have access to Customer Quoting
DB !!";
retVal = false;
}
tDReader2.Close();
this._mSqlCmd.Dispose();
}
}
catch (SqlException sqlExp)
{
erString = sqlExp.ToString();
retVal = false;
}
catch (Exception genExp)
{
erString = genExp.ToString();
retVal = false;
}
and I have tried to DEBUG it and it fails at
SqlDataReader tDReader2 = _mSqlCmd.ExecuteReader();
So dont have clue mate,, why it is coming suddenly,, as the database
previously was on SQL 2K and now moved to SQL 2K5.
Thanks in Advance.
Sunny