invalid date dd/mm/ccyy
I want to use dd/MM/yyyy throughout my .net application, but when i pass
the sql to the .net provider it throughs invalid date error.
I have tried myconn.DateFormat = 'dd/MM/ccyy'
and this also does not work..
please see details below.. any help will be great. thanks
i have <globalization culture="en-GB"/>
in my web.config file..
i am using advantage 10, .net 4.0 and advantage .net provider 10
String SQL = "Select Top 50 xID, STATUS AS Status, C_DATE "+
"FROM tbCon WH开发者_StackOverflow社区ERE C_DATE > '15/05/2006';";
AdsConnection myconn = new AdsConnection();
myconn.ConnectionString = "Data Source=" + DataPath +
";user ID=" + DBUserID + ";password=" + DBPass + ";" +
"ServerType= LOCAL | REMOTE;TrimTrailingSpaces=True; ReadOnly=False;";
myconn.Open();
myconn.DateFormat = 'dd/MM/ccyy';
IDataAdapter iData = new AdsDataAdapter(SQL, myconn);
DataSet dSet = new DataSet();
iData.Fill(dSet);
dt = dSet.Tables[0];
You should avoid passing the data as a string in the query. Use a parameter and pass an actual DateTime object to assign a value to that parameter. This will solve at the root your formatting problems.
精彩评论