Hi,

I'm creating a simple C# ASP.NET app in visual studios and I can’t seem to figure out how to pull values from a single cell when using a table adapter for a SQL database. For example, I have a table adapter named ProductsTableAdapterand I can easily use it to fill a grid view or return rows from the SQL database. However, what if I want to pull a single value from the returned table by a specific column/row?
Does anyone have an example for that syntax?

    DataSet1TableAdapters.ProductsTableAdapter productAdapter = new DataSet1TableAdapters.ProductsTableAdapter();
    DataSet1.ProductsDataTable products;

    products = productAdapter.GetProducts();
    //Not sure where to go from here if I want to pull a value from a single column and row out of the table

Use like this...

con.Open();
SqlCommand cmd = new SqlCommand("select stu_id,t1_eng,t1_tam,t1_mat,t1_sci,t1_soc,t1_tot from sps_stu where stu_id=" + stu_id + " and class='" + cls + "'", con);
cmd.ExecuteNonQuery();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
GridView1.Visible = true;
GridView1.EditIndex = -1;
con.Close();

Hope this helps you.

Have a happy coding...:-D

Ah, I think I get it. So you have to bind it to a grid view in order to get a specific value. Thank you for the help. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.