Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
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
Posted
Updated 17-Nov-10 20:45pm
v2

1 solution

No I'll not solve your problem and neither will I write any code for you.
It seems you're using maybe an "MS Access" DB. That will forfeit the use of
the convert function inside your SQL. AFAIK this is a function only availabe in T-SQL
of MS-SQL Server and won't work here.

Cheers

Manfred
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900