c# - Check if row exists in database -


I have a database and see if a specific record already exists or not. WHERE EMAIL = '"+ + + +" + + "' AND TELEPOOL = '" + + + + + +' '; Npgsql COMMAND COMMAND = New NPGSQL COMMAND:

  string sql = "SELECT COUNT (*) tbl_student (Esquilla, con); int userCount = (int) command.ExecuteScalar (); if (user> gt; 0) {lblMessage.Text = "person already exists";}   

The row that is not working The error message says that it is an invalid artist. I do not have any clue, please help me. int userCount = (int) command.ExecuteScalar ( );

I suspect it is returning a long or try to use the same:

  int userCount = Convert.ToInt32 (command.ExecuteScalar ());   

If that does not work: Ask what it is:

  object val = command.ExecuteScalar () Debug.WriteLine (val.GetType (). Full name);    

Comments

Popular posts from this blog

python - Writing Greek in matplotlib labels, titles -

c# - LINQ to Entities does not recognize the method 'Int32 IndexOf(System.String, System.StringComparison)' method -

Pygame memory leak with transform.flip -