Click here to Skip to main content
15,924,038 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Dear Friends,

I have some Error i can't find out that error: can't find table 0 at retun value.

C#
private DataTable deleteSession(string userSession, string mode)
        {
            DataSet dsData1 = new DataSet();
            SqlConnection sqlCon;
            SqlDataAdapter sqlCmd;

            try
            {
                using (sqlCon = new SqlConnection(ConfigurationManager.ConnectionStrings["conString"].ConnectionString))
                {
                    sqlCmd = new SqlDataAdapter("USP_UserLogin", sqlCon);
                    sqlCmd.SelectCommand.CommandType = CommandType.StoredProcedure;
                    sqlCmd.SelectCommand.Parameters.AddWithValue("@loginID",userSession);
                    sqlCmd.SelectCommand.Parameters.AddWithValue("@password", string.Empty);
                    sqlCmd.SelectCommand.Parameters.AddWithValue("@sessionID", string.Empty);
                    sqlCmd.SelectCommand.Parameters.AddWithValue("@mode", mode);
                    sqlCon.Open();
                    sqlCmd.Fill(dsData1);
                    sqlCon.Close();
                }
            }
            catch
            {
                throw;
            }
            return dsData1.Tables[0];
        }

       

        protected void hnkLogOut_Click(object sender, EventArgs e)
        {
            deleteSession(Convert.ToString(Session["UserID"]), "LOGOUT");
            Session.Abandon();
           // Server.Transfer("~/Login.aspx");
            Response.Redirect("Login.aspx?mode=logout");
        }


[UpDate]
I solved this can't find table problem... Now can't update the values. am using sp for this.
SQL
IF @mode = 'LOGOUT'
BEGIN

	UPDATE [Users]
	SET IsLogin = 0 ,
		userSession = '' 
	WHERE LoginID = @loginID 
          SELECT 0
END


[UpDate]
But, this Executed:
SQL
IF @mode = 'CHANGELOGIN'
BEGIN
	UPDATE [Users]
	SET IsLogin = 1 ,
		userSession = @sessionID ,
		LastLogin = GETDATE() 
	WHERE LoginID = @loginID 
	SELECT 1
END


What I have tried:

didn't update that sp code... above c# and sp code for logout any mistakes in that.
Posted
Updated 24-Apr-16 16:06pm
v8
Comments
Sergey Alexandrovich Kryukov 24-Apr-16 0:22am    
Your catch-throw it a pure crime: this is the same as no exception handling, only wasting CPU time without any purpose.
You should stop doing all your doing and learn exception handling. Don't handle exception locally at all.
—SA
Patrice T 24-Apr-16 1:43am    
I updated your question for you.
Use Improve question to update your question.
Patrice T 24-Apr-16 1:43am    
I updated your question for you.
Use Improve question to update your question.
Karthik_Mahalingam 24-Apr-16 6:01am    
what is the exact issue?
always use Reply button to notify to the concerned user. else they wont get notified.
Vivek.anand34 24-Apr-16 8:36am    
can't update when click the logout button... logout button sp and code above i given.

1 solution

1. You have asked 2 different questions here. After you solved your first question you should have posted the solution and then opened a new question
2. Your update code looks fine so if it is not doing what you want then you have to debug it. None of us know what you want it to do and none of us can run your code so you have to debug it.

You say the SQL code that you wanted to didn't run but another code did? You should see right away then that the variable @mode was not what you thought it should be.

Put breakpoints on your code and see what sql is being executed. This is actually a very simple problem to fix on your own.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900