stuck and confused

G

Guest

Ok, here is my scenario, I have an asp web app that i'm converting to .net.
The app reads files and loads the data into SQL db, now, in my file it has
numbers like, 125.25, 3363.33, 69.00, and when the asp version uploads the
files into the db and I run query analyzer I see the numbers as they are in
the file, but when I upload the same file in my .net version of the app, I
see the numbers like this in query anaylzer: 125.25636363, 3363.3320001,
69.0000001. The columns are defined as floats in the table, and I changed the
types in the code from float to double and even tried decimal, but no luck,
any suggestions on how to get the numbers to show correctly from my .NET app
when I run query anaylzer?
 
K

Karl Seguin [MVP]

how are you going from the text file to code to the database?

are you using xxx.Parse() (like float.Parse()) on a string or something...

Karl
 
G

Guest

the code isn't doing float.parse(), i picked the app up from a former
developer and trying to fix the mess left behind. He's reading the text
files, creating a datatable, then inserting that into the table. in the
datatable, he has something like this:
aColumn = new DataColumn(SALESAMOUNT, System.Type.GetType("System.Single"));
 
K

Karl Seguin [MVP]

is he then doing somethng like

DataRow row = databable.NewRow();
row["SalesAmount"] = someValue;
or
row[12] = someValue;

?

if so, what type is someValue? a string?

Karl
 
G

Guest

like this:

DataRow row = databable.NewRow();
row["SalesAmount"] = arr[1].toString();



Karl Seguin said:
is he then doing somethng like

DataRow row = databable.NewRow();
row["SalesAmount"] = someValue;
or
row[12] = someValue;

?

if so, what type is someValue? a string?

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/


CsharpGuy said:
the code isn't doing float.parse(), i picked the app up from a former
developer and trying to fix the mess left behind. He's reading the text
files, creating a datatable, then inserting that into the table. in the
datatable, he has something like this:
aColumn = new DataColumn(SALESAMOUNT,
System.Type.GetType("System.Single"));
 
K

Karl Seguin [MVP]

well...so far everything looks ok...

can you put a breakpoint and see what format arr[1] is in. My guess is that
it's happening when the value is first loaded from the text file (perhaps
into arr[1]). Can you provide more chunks of code?

Karl

--
http://www.openmymind.net/



CsharpGuy said:
like this:

DataRow row = databable.NewRow();
row["SalesAmount"] = arr[1].toString();



Karl Seguin said:
is he then doing somethng like

DataRow row = databable.NewRow();
row["SalesAmount"] = someValue;
or
row[12] = someValue;

?

if so, what type is someValue? a string?

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/


CsharpGuy said:
the code isn't doing float.parse(), i picked the app up from a former
developer and trying to fix the mess left behind. He's reading the text
files, creating a datatable, then inserting that into the table. in the
datatable, he has something like this:
aColumn = new DataColumn(SALESAMOUNT,
System.Type.GetType("System.Single"));



:

how are you going from the text file to code to the database?

are you using xxx.Parse() (like float.Parse()) on a string or
something...

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/


Ok, here is my scenario, I have an asp web app that i'm converting
to
.net.
The app reads files and loads the data into SQL db, now, in my file
it
has
numbers like, 125.25, 3363.33, 69.00, and when the asp version
uploads
the
files into the db and I run query analyzer I see the numbers as they
are
in
the file, but when I upload the same file in my .net version of the
app, I
see the numbers like this in query anaylzer: 125.25636363,
3363.3320001,
69.0000001. The columns are defined as floats in the table, and I
changed
the
types in the code from float to double and even tried decimal, but
no
luck,
any suggestions on how to get the numbers to show correctly from my
.NET
app
when I run query anaylzer?
 
G

Guest

I did that, and all the way through I can see the number being uploaded as
125.25, so could it be a SQL thing transforming the numbers or something I'm
missing?


Karl Seguin said:
well...so far everything looks ok...

can you put a breakpoint and see what format arr[1] is in. My guess is that
it's happening when the value is first loaded from the text file (perhaps
into arr[1]). Can you provide more chunks of code?

Karl

--
http://www.openmymind.net/



CsharpGuy said:
like this:

DataRow row = databable.NewRow();
row["SalesAmount"] = arr[1].toString();



Karl Seguin said:
is he then doing somethng like

DataRow row = databable.NewRow();
row["SalesAmount"] = someValue;
or
row[12] = someValue;

?

if so, what type is someValue? a string?

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/


the code isn't doing float.parse(), i picked the app up from a former
developer and trying to fix the mess left behind. He's reading the text
files, creating a datatable, then inserting that into the table. in the
datatable, he has something like this:
aColumn = new DataColumn(SALESAMOUNT,
System.Type.GetType("System.Single"));



:

how are you going from the text file to code to the database?

are you using xxx.Parse() (like float.Parse()) on a string or
something...

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/


Ok, here is my scenario, I have an asp web app that i'm converting
to
.net.
The app reads files and loads the data into SQL db, now, in my file
it
has
numbers like, 125.25, 3363.33, 69.00, and when the asp version
uploads
the
files into the db and I run query analyzer I see the numbers as they
are
in
the file, but when I upload the same file in my .net version of the
app, I
see the numbers like this in query anaylzer: 125.25636363,
3363.3320001,
69.0000001. The columns are defined as floats in the table, and I
changed
the
types in the code from float to double and even tried decimal, but
no
luck,
any suggestions on how to get the numbers to show correctly from my
.NET
app
when I run query anaylzer?
 
K

Karl Seguin [MVP]

If the SQL column is a float, you might wanna try changing it to a decimal.
You'll also want to make sure your SqlCommand has a decimal type. Something
like:

command.CommandType = CommandType.Text;
command.CommandText = "INSERT INTO SomeTable (SalesAmount) VALUES
(@SalesAmount)";
command.Parameters.Add("@SalesAmount", SqlDbType.Decimal);
command.Parameters[0].SourceColumn = "SalesAmount";


Karl
--
http://www.openmymind.net/



CsharpGuy said:
I did that, and all the way through I can see the number being uploaded as
125.25, so could it be a SQL thing transforming the numbers or something
I'm
missing?


Karl Seguin said:
well...so far everything looks ok...

can you put a breakpoint and see what format arr[1] is in. My guess is
that
it's happening when the value is first loaded from the text file (perhaps
into arr[1]). Can you provide more chunks of code?

Karl

--
http://www.openmymind.net/



CsharpGuy said:
like this:

DataRow row = databable.NewRow();
row["SalesAmount"] = arr[1].toString();



:

is he then doing somethng like

DataRow row = databable.NewRow();
row["SalesAmount"] = someValue;
or
row[12] = someValue;

?

if so, what type is someValue? a string?

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/


the code isn't doing float.parse(), i picked the app up from a
former
developer and trying to fix the mess left behind. He's reading the
text
files, creating a datatable, then inserting that into the table. in
the
datatable, he has something like this:
aColumn = new DataColumn(SALESAMOUNT,
System.Type.GetType("System.Single"));



:

how are you going from the text file to code to the database?

are you using xxx.Parse() (like float.Parse()) on a string or
something...

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/


Ok, here is my scenario, I have an asp web app that i'm
converting
to
.net.
The app reads files and loads the data into SQL db, now, in my
file
it
has
numbers like, 125.25, 3363.33, 69.00, and when the asp version
uploads
the
files into the db and I run query analyzer I see the numbers as
they
are
in
the file, but when I upload the same file in my .net version of
the
app, I
see the numbers like this in query anaylzer: 125.25636363,
3363.3320001,
69.0000001. The columns are defined as floats in the table, and I
changed
the
types in the code from float to double and even tried decimal,
but
no
luck,
any suggestions on how to get the numbers to show correctly from
my
.NET
app
when I run query anaylzer?
 
C

CsharpGuy

I can't change the column in the db due to it "replication" to other tables,
etc. I did make it a decimal in the SQLCommand, but still no go. I can see
it in the table correctly via enterprise manager, but when i do a query via
Query analzer is where I'm seeing the incorrect number format.


"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:[email protected]...
If the SQL column is a float, you might wanna try changing it to a
decimal. You'll also want to make sure your SqlCommand has a decimal type.
Something like:

command.CommandType = CommandType.Text;
command.CommandText = "INSERT INTO SomeTable (SalesAmount) VALUES
(@SalesAmount)";
command.Parameters.Add("@SalesAmount", SqlDbType.Decimal);
command.Parameters[0].SourceColumn = "SalesAmount";


Karl
--
http://www.openmymind.net/



CsharpGuy said:
I did that, and all the way through I can see the number being uploaded as
125.25, so could it be a SQL thing transforming the numbers or something
I'm
missing?


Karl Seguin said:
well...so far everything looks ok...

can you put a breakpoint and see what format arr[1] is in. My guess is
that
it's happening when the value is first loaded from the text file
(perhaps
into arr[1]). Can you provide more chunks of code?

Karl

--
http://www.openmymind.net/



like this:

DataRow row = databable.NewRow();
row["SalesAmount"] = arr[1].toString();



:

is he then doing somethng like

DataRow row = databable.NewRow();
row["SalesAmount"] = someValue;
or
row[12] = someValue;

?

if so, what type is someValue? a string?

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/


the code isn't doing float.parse(), i picked the app up from a
former
developer and trying to fix the mess left behind. He's reading the
text
files, creating a datatable, then inserting that into the table. in
the
datatable, he has something like this:
aColumn = new DataColumn(SALESAMOUNT,
System.Type.GetType("System.Single"));



:

how are you going from the text file to code to the database?

are you using xxx.Parse() (like float.Parse()) on a string or
something...

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/


Ok, here is my scenario, I have an asp web app that i'm
converting
to
.net.
The app reads files and loads the data into SQL db, now, in my
file
it
has
numbers like, 125.25, 3363.33, 69.00, and when the asp version
uploads
the
files into the db and I run query analyzer I see the numbers as
they
are
in
the file, but when I upload the same file in my .net version of
the
app, I
see the numbers like this in query anaylzer: 125.25636363,
3363.3320001,
69.0000001. The columns are defined as floats in the table, and
I
changed
the
types in the code from float to double and even tried decimal,
but
no
luck,
any suggestions on how to get the numbers to show correctly from
my
.NET
app
when I run query anaylzer?
 
K

Karl Seguin [MVP]

I don't think there's a good solution in that case. It would seem that the
person who designed the database might not have understood what Floats are.
Floating points are an approximate representation of your number - not all
values can't be represented. Decimals are used for exact numbers.

You might want to check out:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/acdata/ac_8_con_03_6mht.asp


Karl
--
http://www.openmymind.net/



CsharpGuy said:
I can't change the column in the db due to it "replication" to other
tables, etc. I did make it a decimal in the SQLCommand, but still no go. I
can see it in the table correctly via enterprise manager, but when i do a
query via Query analzer is where I'm seeing the incorrect number format.


"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:[email protected]...
If the SQL column is a float, you might wanna try changing it to a
decimal. You'll also want to make sure your SqlCommand has a decimal
type. Something like:

command.CommandType = CommandType.Text;
command.CommandText = "INSERT INTO SomeTable (SalesAmount) VALUES
(@SalesAmount)";
command.Parameters.Add("@SalesAmount", SqlDbType.Decimal);
command.Parameters[0].SourceColumn = "SalesAmount";


Karl
--
http://www.openmymind.net/



CsharpGuy said:
I did that, and all the way through I can see the number being uploaded
as
125.25, so could it be a SQL thing transforming the numbers or something
I'm
missing?


:

well...so far everything looks ok...

can you put a breakpoint and see what format arr[1] is in. My guess is
that
it's happening when the value is first loaded from the text file
(perhaps
into arr[1]). Can you provide more chunks of code?

Karl

--
http://www.openmymind.net/



like this:

DataRow row = databable.NewRow();
row["SalesAmount"] = arr[1].toString();



:

is he then doing somethng like

DataRow row = databable.NewRow();
row["SalesAmount"] = someValue;
or
row[12] = someValue;

?

if so, what type is someValue? a string?

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/


the code isn't doing float.parse(), i picked the app up from a
former
developer and trying to fix the mess left behind. He's reading the
text
files, creating a datatable, then inserting that into the table.
in the
datatable, he has something like this:
aColumn = new DataColumn(SALESAMOUNT,
System.Type.GetType("System.Single"));



:

how are you going from the text file to code to the database?

are you using xxx.Parse() (like float.Parse()) on a string or
something...

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/


message
Ok, here is my scenario, I have an asp web app that i'm
converting
to
.net.
The app reads files and loads the data into SQL db, now, in my
file
it
has
numbers like, 125.25, 3363.33, 69.00, and when the asp version
uploads
the
files into the db and I run query analyzer I see the numbers as
they
are
in
the file, but when I upload the same file in my .net version of
the
app, I
see the numbers like this in query anaylzer: 125.25636363,
3363.3320001,
69.0000001. The columns are defined as floats in the table, and
I
changed
the
types in the code from float to double and even tried decimal,
but
no
luck,
any suggestions on how to get the numbers to show correctly
from my
.NET
app
when I run query anaylzer?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top