Hi developers,
I have a csv file that is loaded in datagridview by using dataset.
The problem is:
I want to change dates format in dataset not in datagridview before loading a csv file in datagridview
public static DataSet GetDataset(string filename)
{
string Connectionstring = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=Text;",
Path.GetDirectoryName(filename));
string cmdString = string.Format("SELECT *FROM {0}", Path.GetFileName(filename));
string cmdstring = string.Format(@" select convert(varchar, getdate(), 103) From {0}", Path.GetFileName(filename));
DataSet dataset = new DataSet();
using (OleDbConnection olconn = new OleDbConnection(Connectionstring))
{
olconn.Open();
OleDbDataAdapter adapter = new OleDbDataAdapter();
adapter.SelectCommand = new OleDbCommand(cmdString, olconn);
adapter.SelectCommand = new OleDbCommand(cmdstring, olconn);
adapter.Fill(dataset, "Test");
olconn.Close();
}
return dataset;
}
but when I write a code like this
string cmdstring = string.Format(@" select convert(varchar, getdate(), 103) From {0}, Path.GetFileName(filename));
Error is
undefined function convert in Expression
A main problem is that dateformat change in multiple columns
not single or more dates are split into multiple rows and columns
so I do not know how more columns are changed.
I want to change all of the columns rows dates in dataset, by using this sql query.
please solve my problem and Correct this code