943,565 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 939
  • ASP.NET RSS
Aug 19th, 2009
0

Business Entity project not affected by Globalization in the web.config of the Web Pj

Expand Post »
Hi,

I have 2 projects, the business entity, there I have all the classes mapped from the database and the web project where I fill those business entity classes. Then, I need to store in a DB. I have the globalization set in the web.config on the web project. (VS2008, NET 3.5, SQL 2005)

My problem is when I have an instance of the BE class, and I have a date attribute on it, the value entered is not formatted according the globalization in the web.config, and obviously when I pass to the class to store in the DB it fails due to date format.

I think is missing some configuration... but I googled for it and no luck.

There you have part of my coding:

Business Entity:
vb Syntax (Toggle Plain Text)
  1. Public Class Categoria
  2. Inherits AuditBaseClass
  3.  
  4. Private _categ_id As String
  5. Private _categ_descripcion As String
  6. Private _categ_tipo_item As Integer
  7. Private _categ_parent As String
  8. Private _categ_estado_registro As Char
  9. Private _creado_usuario As String
  10. Private _creado_fecha As DateTime
  11. Private _modificado_usuario As String
  12. Private _modificado_fecha As DateTime
  13.  
  14. [...]
  15.  
  16. Public Property creado_fecha() As DateTime
  17. Get
  18. Return Me._ creado_fecha
  19. End Get
  20. Set(ByVal value As DateTime)
  21. Me._ creado_fecha = value
  22. End Set
  23. End Property
  24.  
  25. [...]
  26.  
  27. End Class

Web Project (WebSite)
vb Syntax (Toggle Plain Text)
  1. Private Sub guardar_datos()
  2.  
  3. Dim oCategoriaWCF As New definiciones.DefinicionesClient '<--- Class to store in DB
  4. Dim oCategoriaBE As New BE.Categoria '<--- Object with the Date Attribute
  5.  
  6. Dim result As Integer = -1
  7.  
  8. oCategoriaBE.id = CInt(Session.Item("data.id"))
  9. oCategoriaBE.categ_descripcion = Me.txtDescripcion.Text.Trim
  10. oCategoriaBE.categ_tipo_item = Me.ddlTipoItem.SelectedValue
  11. oCategoriaBE.categ_parent = Me.ddlParent.SelectedValue.Trim
  12. If oCategoriaBE.id = Nothing Or oCategoriaBE.id = 0 Then
  13. oCategoriaBE.creado_usuario = Session.Item("gen.user_name")
  14. oCategoriaBE.creado_fecha = Now() '<--- Now() method returns the incorrect date format and also the value stored
  15. Else
  16. oCategoriaBE.modificado_usuario = Session.Item("gen.user_name")
  17. oCategoriaBE.modificado_fecha = Now() '<--- Now() method returns the incorrect date format and also the value stored
  18. End If
  19.  
  20. Try
  21. result = oCategoriaWCF.GuardarCategoria(oCategoriaBE) '<---- this method fails when it tries to store in the DB
  22. Catch ex As Exception
  23. result = -2
  24. Finally
  25. oCategoriaWCF.Close()
  26. End Try
  27.  
  28. If result > 0 Then
  29. Me.lblResponse.Text = "Los datos fueron guardados satisfactoriamente"
  30. carga_datos()
  31. limpiar_controles()
  32. Else
  33. Me.lblResponse.Text = "Hubo un error al guardar los datos"
  34. End If
  35.  
  36. oCategoriaWCF = Nothing
  37. End Sub

web.config

xml Syntax (Toggle Plain Text)
  1. <system.web>
  2. <globalization requestEncoding="ISO-8859-1" responseEncoding="ISO-8859-1" uiCulture="es-PE" culture="es-PE" />
  3. </system.web>


Thanks!
Similar Threads
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
culebrin is offline Offline
62 posts
since Aug 2007
Aug 20th, 2009
0

Re: Business Entity project not affected by Globalization in the web.config of the Web Pj

I never found a solution to the exact same problem you're having. I had a BE project that did transaction posting to a payment gateway and I tested it on a winform application and it worked perfectly .. then when I used it from a web application assembly it failed and I spent hours to figure out that the web apps and desktop apps format differently.

I never found a solution using localization. I began explicitly calling the .ToString() with the desired DateFormat options. The number of decimal places, separator, etc also varied between the desktop and web apps.
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Getting mac address and client side encryption
Next Thread in ASP.NET Forum Timeline: Where to put Google Analytic code?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC