|
-
November 18th, 2010, 09:16 AM
#1
C#/SQL Null Exception Error
Hi All;
Im having an issue with running and returning values from an SQL stored procedure.
Actually - the running and the retrieving works fine, its using the values returned that is an issue.
I can see the variable has the returned values, but i cant add them to any form object.
I keep getting a 'NULL REFERENCE EXCEPTION" at the code below, even tho i do a null check and i know the value is not (nor ever will be) null.
Any help would be appreciated!!
string sessionname = "";
//Run Stored Procedure
OleDbConnection conn = new OleDbConnection("CONNSTRING");
conn.Open();
OleDbCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "msgStartSession";
cmd.Parameters.Clear();
cmd.Parameters.AddWithValue("@empid", empid);
OleDbDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
mSESSION = Convert.ToInt32(rdr.GetValue(0).ToString());
sessionname = rdr.GetValue(1).ToString();
}
conn.Close();
conn.Dispose();
if (String.IsNullOrEmpty(sessionname) != true)
lblNAME.Text = sessionname; //ERROR HERE
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|