i have this code...i m retreiveing did from selected name........
i want to assign this to varible because i want to use this variable to another place...
i hope i will get help here..

MyDataAdapter = new SqlDataAdapter("select D_Id from tblDepart where D_Name = '" + D_Name + "'", Myconnection);
         myDataSet = new DataSet();
       int a = Convert.ToInt16(myDataSet);

Edited 5 Years Ago by __avd: Added [code]..[/code] tags.

Fill() method create an instance of DataTable and DataTable instance hold references of rows (fetched result).

int a=0;
    a= (int) myDataSet.Tables[0].Rows[0][0]; //1st row and 1st column

Just to add:
... be careful here. adatapost is correct, but be careful in two things
- row index
- column index

You have to state the correct indexes, and for the column you can even state the column name!

i want to assign a variable which contains set of values in a row orderby rollno.
that variable would be send to mobile number as a text. how to write the code. can i use here for datatable or datareader.quickly. send ur replies to my mail id also. Here is my mail id vpsingh136@gmail.com

This question has already been answered. Start a new discussion instead.