Skip to content
Loading
  • Junaid Musla
    0
    Hi,

    The purpose of the expression parameter of DataColumn is not what you want to achieve. I tried your code and got this as one of the possible solution.
     
    1. DataTable dt = new DataTable();    
    2. dt.Columns.AddRange(new DataColumn[3] {    
    3. new DataColumn("SRNO", typeof(Int32)),    
    4. new DataColumn("BANKID", typeof(Int32)),    
    5. new DataColumn("IMPORT_DATE_TIME",typeof(string))  // set this of type string.  
    6. });    
    7. dt.Rows.Add(1, 1, DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss tt"));  // Format the date value when you add it to the column.  
    Also you can refer this for expression parameter:

    https://docs.microsoft.com/en-us/dotnet/api/system.data.datacolumn.expression?view=netcore-3.1#System_Data_DataColumn_Expression 
    0