Arjun_Sarankulu -3 Junior Poster

I have a csv upload utility for my company.

When user run the application in the drop down user get the table name in which insert the data (data from file browse)
when table column type is date it gives error "source type of string cannot be cannot to destination date type".
Run time i cannot find the column data type
For this i have done the below

List<string> lst = new List<string>();

String query_for_datatype = "select top 1 * from " + tablename;
SqlCommand cmd_type = new SqlCommand(query_for_datatype, connection_string1);
SqlDataAdapter adapter = new SqlDataAdapter(cmd_type);
adapter.Fill(ds_type);
DataTable item = ds_type.Tables[0];
foreach (DataColumn col in item.Columns)
{
    type = Convert.ToString(col.DataType);
    lst.Add(type);

}

Now in collection i have datatype for all the Columns

in SQLBulkcopy

I am adding the File first line as Column header
and for this i need to specifiy datatype which i need to take form collection

string line = sr.ReadLine();

string[] value = line.Split(',');

DataTable dt = new DataTable();

DataRow row;

foreach (string dc in value)
{

    Type type1 = Type.GetType(lst[j]);
    dt.Columns.Add(new DataColumn(dc)); //here the second parameter required system.type which is there in collection but in collection it is string how to use the collection value(Collection contain System.string, system.Datetime etc) which i want to use as second parameter
    j++;
}

Search a lot but didnt get.