Well the first thing to tell you is to use the debugger, set some breakpoints, and see what values are where in your code:
What value is assigned at
int count = ...ExecuteScalar();
Not what you are expecting?
Maybe we should create some values for those Session variables you are usingAnd naturally I am going to tell you to use these in your query as parameters- I see in your INSERT/UPDATE block you know how to use
cmd.Parameters.AddWithValue()
So lets start with this block of code, have a debug
string sesClientID = Session["clientid"];
string sesClientIDa = Session["clientida"];
MySqlCommand cmdCount = new MySqlCommand("SELECT count(*) from travel WHERE clientid=@ClientID AND clientida=@ClientIDa", con);
cmdCount.Parameters.AddWithValue("@ClientID", ClientID);
cmdCount.Parameters.AddWithValue("@ClientIDa", ClientIDa);
con.Open();
int count = Convert.ToInt16(cmdCount.ExecuteScalar());
if (count > 0)
So working from here you should be able to see what your Session values are and if it is finding it in the DB or not. Continue this way through your code, and remember to ALWAYS USE parameters.
One part of discontinuity that I see is that you are using the TextBox values for the INSERT statement as opposed to the Session variables.
You may want to check those as well and compare to see if they are matching or not.