Hi there,
I'm wondering if I was on a write truck, could you please tell me?
I have a Button, textbox and a datagrid that updates. the datagrid is ok, but now I'm trying to get the user put an id number in the textbox and by the click of the button it selects immediatly the corresponding id number in the data grid.
this is the code I'm using:
private void bttok_click(obj ect sender, System.EventArg s e)
{
con.Open();
try
{
using (SqlCommand myCommand = new SqlCommand("sel ect * from employee where @ID="+txtname.T ext,con))
{
SqlParameter myparam = new SqlParameter("@ ID",SqlDbType.T ext);
myparam.Value=I D;
myCommand.Param eters.Add(mypar am);
using (SqlDataAdapter myAdapter=new SqlDataAdapter( myCommand))
{
DataSet ds = new DataSet();
myAdapter.Fill( ds);
dgupdate.DataSo urce=ds;
dgupdate.DataBi nd();
}
}
catch(Exception err)
{
Console.WriteLi ne(err.Message) ;
}
finally
{
con.Close();
}
}
I'm wondering if I was on a write truck, could you please tell me?
I have a Button, textbox and a datagrid that updates. the datagrid is ok, but now I'm trying to get the user put an id number in the textbox and by the click of the button it selects immediatly the corresponding id number in the data grid.
this is the code I'm using:
private void bttok_click(obj ect sender, System.EventArg s e)
{
con.Open();
try
{
using (SqlCommand myCommand = new SqlCommand("sel ect * from employee where @ID="+txtname.T ext,con))
{
SqlParameter myparam = new SqlParameter("@ ID",SqlDbType.T ext);
myparam.Value=I D;
myCommand.Param eters.Add(mypar am);
using (SqlDataAdapter myAdapter=new SqlDataAdapter( myCommand))
{
DataSet ds = new DataSet();
myAdapter.Fill( ds);
dgupdate.DataSo urce=ds;
dgupdate.DataBi nd();
}
}
catch(Exception err)
{
Console.WriteLi ne(err.Message) ;
}
finally
{
con.Close();
}
}