I wanted to retrieve database records of every id inside of
list<int> list_of_id = new list<int>();
then store all gathered record of every id that is inside of
list<int> list_of_id = new list<int>();
into
DataTable dt = new DataTable();
I'm looking forward to your suggestion and replies.
What I have tried:
Here is what I've done:
I'm already done with the first requirement which is retrieving all id of non-member from user_register_table and store all of it into
list<int> list_of_id = new list<int>();
using(MySqlConnection con = new MySqlConnection(connectionstring))
{
con.Open();
using(MySqlCommand com = new MySqlCommand("SELECT * FROM
user_register_table WHERE user_status='none-member'",con))
{
MySqlDataReader reader = com.ExecuteReader();
while (reader.Read())
{
list_of_id.Add((int)reader["register_id"]);
}
reader.Dispose();
}
I converted list<int> items into array;
int[] ints = all_joined_group_id.ToArray();
Last, is to fill
DataTable dt = new DataTable();
with records from
MySqlDataAdapter adp = new MySqlDataAdapter(com)
using (MySqlCommand com = new MySqlCommand("SELECT * FROM clientdebt_table WHERE
clientdebt_id IN (@unique_ids)", con))
{
com.Parameters.AddWithValue("@unique_ids",ints);
using (MySqlDataAdapter adp = new MySqlDataAdapter(com))
{
adp.Fill(dt);
}
}
}