TODO:
Have you ever wanted to convert a SqlDataReader to a DataTable in C#?
SOLUTION:
DataTable datatable = null;
string ErrorMessage = "";
try
{
using (SqlConnection myConnection = new SqlConnection(ConnectionString))
{
using (SqlCommand cmd = new SqlCommand("some sql here", myConnection))
{
myConnection.Open();
using (SqlDataReader reader = cmd.ExecuteReader())
{
datatable = new DataTable();
datatable.Load(reader);
}
}
}
}
catch (Exception ex)
{
ErrorMessage = ex.Message;
}
NOTES:
There are no notes on this topic.
TODO:
Have you ever wanted to convert a List<string> to a comma delimited string?
SOLUTION:
List<string> list = new List<string>();
list.Add("blah");
list.Add("blah1");
list.Add("blah2");
list.Add("blah3");
string result = String.Join(",", list.ToArray());
NOTES:
There are no notes on this topic.