Thanks;
i try to create method return DataTable value as following:
public DataTable table(string e,string p)
{
SqlParameter sqlparameter;
DataTable dt = null;
SqlConnection cn = new SqlConnection();
cn.ConnectionString = "server=XXX; database=Test; integrated security=true";
try
{
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandTimeout = 0;
cmd.CommandText = "StoredProcedure1";
sqlparameter = new SqlParameter();
sqlparameter.ParameterName = "@Emp_id";
sqlparameter.SqlDbType = SqlDbType.NChar;
sqlparameter.Value = e;
sqlparameter.Direction = ParameterDirection.Input;
cmd.Parameters.Add(sqlparameter);
sqlparameter = new SqlParameter();
sqlparameter.ParameterName = "@Password";
sqlparameter.SqlDbType = SqlDbType.NChar;
sqlparameter.Value = p;
sqlparameter.Direction = ParameterDirection.Input;
cmd.Parameters.Add(sqlparameter);
SqlDataAdapter sqlDA = new SqlDataAdapter();
dt = new DataTable();
sqlDA.SelectCommand = cmd;
cn.Open();
sqlDA.Fill(dt);
cn.Close();
}
catch (Exception ex)
{
Response.Write("Error");
}
return dt;
}
And in button i invoke the method as following :
protected void Button1_Click(object sender, EventArgs e)
{
string EmpID = TextBox1.Text;
string password = TextBox2.Text;
GridView1.DataSource = table(EmpID, password);
GridView1.DataBind();
}
but nothing happen i don't know if there something wrong, the GridView1 not display and the in database not result i go to my database and right click then show table data but no any thing plezzzzzzz :( if i have any error tell me. Note, when am i run there are no any error in code .
Thanks All :)