CMsSqlDatabase.vb
Public Overrides Function getValueFor(ByVal tempValue As Object) As String
.
.
Case VariantType.Date
' Started Modified By cpf.co.th
Dim OriginalCulture As System.Globalization.CultureInfo
Dim TempCulture As System.Globalization.CultureInfo
TempCulture = New System.Globalization.CultureInfo("en-US")
OriginalCulture = System.Threading.Thread.CurrentThread.CurrentCulture
System.Threading.Thread.CurrentThread.CurrentCulture = TempCulture
System.Threading.Thread.CurrentThread.CurrentUICulture = TempCulture
' End Modified By cpf.co.th
dd = CType(tempValue, DateTime)
If dd = Date.MinValue Then
tempRetorno = "NULL"
Else
If dd.Date.Ticks = 0 Then
'MSSQL doesn't support dates with years less than 1753, so time only
'values that format to "0001-01-01 11:23:00" for example produce errors.
'If it's just a time we will only return time portion.
tempRetorno = "'" & dd.ToString("HH:mm:ss") & "'"
Else
tempRetorno = "'" & dd.ToString("yyyy-MM-dd HH:mm:ss") & "'"
End If
End If
' Started Modified By cpf.co.th
System.Threading.Thread.CurrentThread.CurrentCulture = OriginalCulture
System.Threading.Thread.CurrentThread.CurrentUICulture = OriginalCulture
' End Modified By cpf.co.th
Thank you
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm not sure what problem you are trying to fix. The dates are generated in a specific format that MSSQL server want and there is no locale specific code (that I am aware of) so why do you need to set the culture information?
- Richard.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm not sure to specific this point Because My colleague has found Its in where condition for createdDate and ModifiedDate.
It's Translated Year to 2547 instead 2004
My Config Server
- Sql Server 2000 Default Language British English this year is 2004
- Asp.net th-TH (not sure) this year is 2547 (sure)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
CMsSqlDatabase.vb
Public Overrides Function getValueFor(ByVal tempValue As Object) As String
.
.
Case VariantType.Date
' Started Modified By cpf.co.th
Dim OriginalCulture As System.Globalization.CultureInfo
Dim TempCulture As System.Globalization.CultureInfo
TempCulture = New System.Globalization.CultureInfo("en-US")
OriginalCulture = System.Threading.Thread.CurrentThread.CurrentCulture
System.Threading.Thread.CurrentThread.CurrentCulture = TempCulture
System.Threading.Thread.CurrentThread.CurrentUICulture = TempCulture
' End Modified By cpf.co.th
dd = CType(tempValue, DateTime)
If dd = Date.MinValue Then
tempRetorno = "NULL"
Else
If dd.Date.Ticks = 0 Then
'MSSQL doesn't support dates with years less than 1753, so time only
'values that format to "0001-01-01 11:23:00" for example produce errors.
'If it's just a time we will only return time portion.
tempRetorno = "'" & dd.ToString("HH:mm:ss") & "'"
Else
tempRetorno = "'" & dd.ToString("yyyy-MM-dd HH:mm:ss") & "'"
End If
End If
' Started Modified By cpf.co.th
System.Threading.Thread.CurrentThread.CurrentCulture = OriginalCulture
System.Threading.Thread.CurrentThread.CurrentUICulture = OriginalCulture
' End Modified By cpf.co.th
Thank you
Hi Leng,
I'm not sure what problem you are trying to fix. The dates are generated in a specific format that MSSQL server want and there is no locale specific code (that I am aware of) so why do you need to set the culture information?
- Richard.
I'm not sure to specific this point Because My colleague has found Its in where condition for createdDate and ModifiedDate.
It's Translated Year to 2547 instead 2004
My Config Server
- Sql Server 2000 Default Language British English this year is 2004
- Asp.net th-TH (not sure) this year is 2547 (sure)
Ah, I see! It's used the Thai year, not the US year. The same problem could easily occur in other locales as well.
OK. I'll have a look at the code in more detail and make changes to the other db providers as well.
Thanks :-)
Richard.
The code has been changed and CVS updated.
Once again, thanks for the fix :-)