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

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2007
Posts: 56
Reputation: culebrin is an unknown quantity at this point 
Solved Threads: 1
culebrin culebrin is offline Offline
Junior Poster in Training

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

 
0
  #1
Aug 19th, 2009
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:
  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)
  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

  1. <system.web>
  2. <globalization requestEncoding="ISO-8859-1" responseEncoding="ISO-8859-1" uiCulture="es-PE" culture="es-PE" />
  3. </system.web>


Thanks!
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,215
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 573
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

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

 
0
  #2
Aug 20th, 2009
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.
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC