Showing posts with label sql2000. Show all posts
Showing posts with label sql2000. Show all posts

Monday, March 12, 2012

Number are displayed in the wrong format

Hi

I'm not sure if this is a .net or a SQL issue. My development machine is using SQL 2005 while the live server is SQL2000. I have a smallmoney field in the database for holding a house rent. The following is used to display the contents on the page

<asp:Label ID="lblrent" runat="server" Text='<%# Bind("rent", "(0:0.00)") %>'></asp:Label
In development, the number is displayed correctly, with the decimal place, .e.g. 200.50 but on the live server the number is displayed as 20050,00.
What I have noticed in the database is that the number is held differently
SQL 2005 - 200.5000
SQL 2000 - 20050

Is there a difference between SQL 2000 and 2005? How do I get around this problem?

Many thanks

Try using this as your formatting string. I'm not sure what would cause that problem.

{0:c}

I hope that helps,

Brendan

|||

oops sorry do both of them list the same datatype for the column? It should be money or smallmoney for both of them. If it is not it might still have let you insert the value and now would be giving an incorrect result.

|||

My guess would be that one of your servers is set to a culture that you aren't expecting. My guess would be the production webserver is set to a culture that uses "," as the decimal separator, and "." as the thousands separator (Considering that it printed the number 20050 as 20050,00).

|||

The datatype for the columns in both databases is smallmoney, which is why I'm a bit confused as to why they are being displayed differently. Even if I manually change the entry in the SQL2000 db to a number with a decimal place, the decimal place is removed.

I tried using {0:C} as the formatstring and what I get back is 20.050,00 € on the server with SQL2000. With SQL2005 I get £200.50.

The server where the website hosted is with 1and1 using a MS Business PRO package, so I don't really have a lot of control over the SQL config. I have e-mailed tech support asking for some more information on the default settings for the SQL setup.

If I am using the same code and the same formatstring, the problem must be with the database setup. Right?

|||

No.

Put this in your web.config somewhere in the <system.web> tags:

<globalizationculture="en-US"uiCulture="en-US"/>

Now the SQL2000 server should show $20,500.00 and the SQL2005 server should show $200.50.

How did you get the data from one server to the other? Because whatever process you used also had culture problems, and the data didn't get moved correctly.

|||

Thanks. That solved the problem. I changed it to en-GB, as this is a UK site and I need the £ symbol displayed. The numbers are being displayed correctly.

Only the table structure was imported to the server. No data was imported for the table with the money columns. The users are entering the data themselves.

I exported the table structure using the SQL Database Publishing Wizard. I changed the option 'script for server version' to SQL Server 2000 and left the other options at default. Should I have changed any of the other options?

Nulls vs Blanks

Until yesterday it was imposible to delete a field that did not allow nulls
in Enterprise manager (SQL2000) the InfoPath Clients connected to such tables
saw red asterisks in all the required fields according to the information
provided by the SQL schema.
This has now changed on all instances and all servers without apparant
reason. now I can delete a field that does not allow nulls and it is
registered as a blank. Infopath clients are not forced to include all
required fields prior to submitting.
What could have changed?
Thanks
IT PHYTOSANThis is a multi-part message in MIME format.
--080302080803080309060001
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
This might be better off posted to an InfoPath newsgroup (like
microsoft.public.infopath).
--
*mike hodgson*
http://sqlnerd.blogspot.com
IT PHYTOSAN wrote:
>Until yesterday it was imposible to delete a field that did not allow nulls
>in Enterprise manager (SQL2000) the InfoPath Clients connected to such tables
>saw red asterisks in all the required fields according to the information
>provided by the SQL schema.
>This has now changed on all instances and all servers without apparant
>reason. now I can delete a field that does not allow nulls and it is
>registered as a blank. Infopath clients are not forced to include all
>required fields prior to submitting.
>What could have changed?
>Thanks
>IT PHYTOSAN
>
--080302080803080309060001
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<tt>This might be better off posted to an InfoPath newsgroup (like
microsoft.public.infopath).</tt><br>
<div class="moz-signature">
<title></title>
<meta http-equiv="Content-Type" content="text/html; ">
<p><span lang="en-au"><font face="Tahoma" size="2">--<br>
</font></span> <b><span lang="en-au"><font face="Tahoma" size="2">mike
hodgson</font></span></b><span lang="en-au"><br>
<font face="Tahoma" size="2"><a href="http://links.10026.com/?link=http://sqlnerd.blogspot.com</a></font></span>">http://sqlnerd.blogspot.com">http://sqlnerd.blogspot.com</a></font></span>
</p>
</div>
<br>
<br>
IT PHYTOSAN wrote:
<blockquote cite="mid6513D024-96EB-4CF5-82B8-7134F4812D09@.microsoft.com"
type="cite">
<pre wrap="">Until yesterday it was imposible to delete a field that did not allow nulls
in Enterprise manager (SQL2000) the InfoPath Clients connected to such tables
saw red asterisks in all the required fields according to the information
provided by the SQL schema.
This has now changed on all instances and all servers without apparant
reason. now I can delete a field that does not allow nulls and it is
registered as a blank. Infopath clients are not forced to include all
required fields prior to submitting.
What could have changed?
Thanks
IT PHYTOSAN
</pre>
</blockquote>
</body>
</html>
--080302080803080309060001--

Nulls vs Blanks

Until yesterday it was imposible to delete a field that did not allow nulls
in Enterprise manager (SQL2000) the InfoPath Clients connected to such table
s
saw red asterisks in all the required fields according to the information
provided by the SQL schema.
This has now changed on all instances and all servers without apparant
reason. now I can delete a field that does not allow nulls and it is
registered as a blank. Infopath clients are not forced to include all
required fields prior to submitting.
What could have changed?
Thanks
IT PHYTOSANThis might be better off posted to an InfoPath newsgroup (like
microsoft.public.infopath).
*mike hodgson*
http://sqlnerd.blogspot.com
IT PHYTOSAN wrote:

>Until yesterday it was imposible to delete a field that did not allow nulls
>in Enterprise manager (SQL2000) the InfoPath Clients connected to such tabl
es
>saw red asterisks in all the required fields according to the information
>provided by the SQL schema.
>This has now changed on all instances and all servers without apparant
>reason. now I can delete a field that does not allow nulls and it is
>registered as a blank. Infopath clients are not forced to include all
>required fields prior to submitting.
>What could have changed?
>Thanks
>IT PHYTOSAN
>