locked
Date & Currency in Globalization Vs Database Transactions RRS feed

  • Question

  • User-1866268973 posted

    Hi guys,

    I've a website which is English and Arabic, uses Master Pages, and that of multilingual thing was already very well answered by Vivek. http://forums.asp.net/thread/1408068.aspx

    Now continueing with that, I'm facing the following problems for which till now I'm unable to findout a solve, would be greatfull if somebody suggest a way for that

    Problem-1 :

    I've a created a View in SQL Server which retreives the records of (DATE > USER ENTERED CRITERIA DATE) 
    The problem which I've is that
    SQL Server Uses MM-DD-YYYY format for date, While in English Language of Website, it works well.
    But when I convert it to Arabic.. the date format in Arabic Goes DD-MM-YYYY, and this Creates problem in Query
    that wrong (month & date shuffle) or invalid (Month greater than 12) passed to SQL Server.

    I've made a solution for that for time being as I'm detecting the current Culture and then formatting the date appropriately
    i.e. if Arabic put Date to Month place and Month to Date place
    if "Arabic"
       DD-MM-YYYY  =>=> MM-DD-YYYY

    so that this date could be passed to SQL server.


    I would be thankful if somebody could provide me some genuine way of doing this instead of messing around with alternative custom functions which do not/fail or generate error in a couple of unhandled or unexpected situations.


    Problem-2 :

    Also For both currency & Date, I would need to know that if I change the language from English to Arabic

    can 5000 be convered to ۵۰۰۰

    Where ۵۰۰۰ is the Arabic representation (Arabic digits) for 5000

    Same question is for Date too.

    Regards

    Thursday, October 19, 2006 3:38 AM

All replies

  • User1416329745 posted

    I think all of the above in WinForm and WebForm is covered by Microsoft in the link below.  Hope this helps.

    https://www.microsoft.co.ke/middleeast/msdn/arabicsupp.aspx

    Tuesday, October 24, 2006 6:24 PM
  • User-1866268973 posted
    hi Caddre

    Thanks for your reply, atleast I got to some corner of the rope. The digit-substitution is the solve for converting the numeric value to a native numeric value

    but again 

    that is working only with windows forms (and with the drawString method) but in ASP.NET there is not example given that how would a string substitute of that numeric value gets returned in the native numeric values

    I'm trying searching it from the web as well as searching for any appropriate function in the object browser but till now, got now clue..

    I hope that some developer must have done it and just like you he is just a single view away, I mean that if he sees this post he would definetely reply !

    cheers !
    Wednesday, October 25, 2006 4:17 AM
  • User1416329745 posted

    If you want to do some work I can help you with both the first link will show you how to create SQL Server DateTime that is not language dependent and the second lin is the function to help you get any date when you have completed that post again and I can help you with the currency.  And if I find the digital subtitution link I will post.  Hope this helps.

    http://www.karaszi.com/SQLServer/info_datetime.asp
    http://msdn.microsoft.com/en-us/library/ms178635.aspx

    Wednesday, October 25, 2006 9:39 AM
  • User1416329745 posted

    Here are the digital subtitution links I promised one is the Microsoft expert on the subject so you can send him an email if needed.  Hope this helps.

    http://blogs.msdn.com/michkap/archive/2005/09/09/462920.aspx

    http://www.microsoft.com/middleeast/arabicdev/windows/winxp/DigitsSupport.aspx#arabic


    http://msdn.microsoft.com/en-us/library/system.globalization.numberformatinfo.digitsubstitution.aspx

    Wednesday, October 25, 2006 10:10 AM
  • User-1866268973 posted

    hi Caddre

    I really Thank you for your prompt replies.

    I've got to the solution of sql server, though with your post, thanks again.

    still got stuck in number substitution

    I've followed the stype given in the link sent by you and implemented the customize options.

    One thing which i noted in that, screenshot description was that the default language of the PC which was in the screen shot was ar-EG i.e. ejyptian but my computer's language is English, but I've Arabic installed on my PC from the regional options

    but instead i selected "arabic-uae" from the language drop down and applied as was shown in the screen shot

    now here I'm copy/pasting an small one page program (ASP.NET 2.0) which should work find in number substitution under ideal situation but in reality .... its not.

     

    Imports System.Drawing
    Imports System.Drawing.Graphics
    Imports System.Threading
    Imports System.Globalization
    
    Partial Class numbersubs
        Inherits System.Web.UI.Page
    
        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim myculture As System.Globalization.CultureInfo = New System.Globalization.CultureInfo("ar-AE")
            Thread.CurrentThread.CurrentCulture = myculture
            Thread.CurrentThread.CurrentUICulture = myculture
            Dim strNativeNumbers() As String = {"۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹"}
            Label1.Text = TextBox1.Text
            Dim nfi As NumberFormatInfo = myculture.NumberFormat
            myculture.NumberFormat.DigitSubstitution = DigitShapes.Context
            nfi.DigitSubstitution = DigitShapes.Context
            nfi.NativeDigits = strNativeNumbers
            Dim DBL As Double = Val(TextBox1.Text)
            Label2.Text = DBL.ToString("N", nfi)
            Response.Write(Me.Culture.ToString)
        End Sub
    End Class

    In the above ASPX page, I've one command buton control, two one textbox and two label controls
    textbox where i enter any numeric value
    label1 where i display default english digits
    label2 where i want to display the substituted values
    button , whose click event is the code block

    I hope that you've got the clear situation as well as that is the exact code which doesnt work for me

    Please let me know if I'm making mistake somewhere or missing out some line of code whcih makes this code fail.

    regards

    Thursday, October 26, 2006 3:21 AM