conn = new SqlConnection(@"Data Source=ASHISH-PC\SQLEXPRESS; initial catalog=bank; integrated security=true");
ada = new SqlDataAdapter("select total_amount from debit_account where account_no=12", conn);
ds = new DataSet();
ada.Fill(ds);
Now, I want to print value of the dataset… how? Please help me.
I think, in this case, you’d be better off (performance-wise) to use a
SqlCommandinstead of the adapter and dataset, and invoke theExecuteScalarmethod.See http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.executescalar.aspx
If you must use the data set, however,
ds.Tables[0].Rows[0]["total_amount"]should retrieve your value. You will probably need to type cast the value, though.