I want to retrieve all User_id's next after my entered User_id referencing each other from the table by Reference_id, the code below gives the exact result but it retrieves all User_id's from "2001 to 2005".
I want if i enter the "2002" as User_id from a textbox then it must retrieve from "2003 - 2005"
Table_xyz column User_id have value= 2001, 2002, 2003, 2004, 2005
Table_xyz column Reference_id have value= 2000, 2001, 2002, 2003, 2004
var gCmd = new SqlCommand(@"SELECT User_id FROM Table_xyz", nCon);SqlDataAdapter Sda = new SqlDataAdapter(gCmd);DataTable Dt = new DataTable(); Sda.Fill(Dt);for (int i = 0; i < Dt.Rows.Count; i++){string referenceid = Dt.Rows[i]["User_id"].ToString();var gCmd1 = new SqlCommand(@"SELECT User_id FROM Table_xyz WHEREReference_id = '" + referenceid + "'", nCon);SqlDataAdapter Sda1 = new SqlDataAdapter(gCmd1);DataTable Dt1 = new DataTable();Sda1.Fill(Dt1);Response.Write(referenceid);}
I tried adding "SELECT User_id FROM Table_xyz WHERE User_id = '2001'" to the first command but it returns only a single value where User_id matched "2001"
Gokhul VarmanPosted Aug 4, 2017, 8:29 AM
Ruchi SharavatPosted Aug 4, 2017, 7:35 AM
Abdur RaziquePosted Aug 4, 2017, 7:27 AM
My User_id and Reference_id will have alfa numeric values too (like: ricky_global9, mark09, robin_123)
And your said "Recursive command" will work perfect only if the the datatype is INT or Convert.ToInt.
So the issue still persist for me.
Abdur RaziquePosted Aug 4, 2017, 7:27 AM
My User_id and Reference_id will have alfa numeric values too (like: ricky_global9, mark09, robin_123)
And your said "Recursive command" will work perfect only if the the datatype is INT or Convert.ToInt.
So the issue still persist for me.
Ruchi SharavatPosted Aug 4, 2017, 6:49 AM