hi frnd's ,
please help me in explaining me how to retrieve a selected field from database in c# language..
For example .
entering a roll no in a text box , then the data corresponding to that roll no. should be retrived from the database and should be displayed in grid view.
Loading

ajay rajuPosted Jun 4, 2010, 5:28 AM
string str = "select sub1,sub2 from marks where rollno = " + TextBox1.Text;
SqlDataAdapter da = new SqlDataAdapter (str,cn);
DataSet ds = new DataSet();
da.Fill(ds,"marks");
Gridview1.Datasource = ds.Tables[0];
Gridview1.DataBind();
it will may helps you. if it helps you please mark as Accepting Answer.
Thanks.
LiyaPosted Jun 4, 2010, 4:35 AM
int rolNo = 0;
bool isOk = Int32.TryParse(MyTextBox.Text, out rollNo);
if (isOk)
{
string sql = "select columnA, cilumnB from myTable where ColumnRollNo = " + Convert.ToInt32(MyTextBox.Text);
...here go to db in the way you work, and run the query, or call the stored procedure with the parameter rollNo
}