i want to check is exist a logic name in Logic table or not. my query and procedure working properly but in C# code it doesn't work correctly.it suppose to ExecuteSchalar() return 0 or 1 and then i check it and show a messagebox or proceed other codes.my codes are below
string LogicNameCheck_Query = "exec searchLogicName '{0}'";
LogicNameCheck_Query = string.Format(LogicNameCheck_Query , txtLogicName);
SqlCommand sc = new SqlCommand();
sc.Connection = sqlConnection1;
sc.CommandText = LogicNameCheck_Query;
if (sqlConnection1.State != ConnectionState.Open)
{
sqlConnection1.Open();
}
int existLogicName = Convert.ToInt32(sc.ExecuteScalar());
MessageBox.Show(existLogicName +"");
if(existLogicName == 1)
{
MessageBox.Show("name is exist");
return;
}
if (sqlConnection1.State != ConnectionState.Closed)
{
sqlConnection1.Close();
}
below is searchLogicName procedure code:
ALTER procedure [dbo].[searchLogicName]
@LogName varchar(50)
as
IF EXISTS (select * from Logic where LogicName = @LogName)
select 1 else select 0