Showing posts with label files. Show all posts
Showing posts with label files. Show all posts

Saturday, March 24, 2012

Stripping the format of files.

Hi Guys,

I am fairly new to asp.net but am embarking on a project based on asp.net I am wondering if anyone has any experience or knowledge on how to strip the formatting of different documents? Maybe for a start, how do you strip the formatting of styles and stuff in MS Words to just purely text?

Regards,

Raymond

Hi,

if you mean that you just want to get the text itself and not the colors, ... you can copy paste it into notepad and from notepad copy paste to somewhere else.

Grz, Kris.


Hi Kris,

Thanks for your input. Actually I am looking more at the coding level because I need to strip the formatting of the file automatically before I can do further comparing of the contents in string or text format.

Regards,
Raymond


Is there anyone with the relevant experience who can share their knowledge?

Thanks!

Raymond

Stripping text files

Hi all,

I'm trying to have my ASP.NET application read in a text file, and put the characters into a string.

I realized that there are some weird symbols (a square) between the texts - I think it's either a carriage return or a newline character, and want to take them out by the Trim method.

Does anybody know how I can remove those symbols? Thanks!You can use this overload

public string Trim(params char[]);
, if you know which characters you want to remove.
Most likley candidates are chr(10) (carriage return) followed by chr(13) line feed, especiallly if you are working with report files or anything unix based.

Regards

Jeff............

Strong name signature could not be verified

Hi,

I've downloaded a set of C++ files written by someone else (a wrapper for the ImageMagick object called MagickNet), created an snk file using sn -k and figured out how to add this reference to the assembly (I'm not a C++ programmer, but I figured out to use assembly:AssemblyKeyFileAttribute in AssemblyInfo.cpp). The result seems to compile fine.

However, when I add a reference to the dll in VS2005 and try to compile my project there, I get:

Error 4 Could not load file or assembly 'MagickNet' or one of its dependencies. Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)

I get something similar trying to use gacyutil to add the dll to the GAC.

Does anyone know what on earth is going on here? I've googled this and it looks like a pretty rare error message, certainly no-one else out there seems able to shed any light on it.

Can anyone assist?

Cheers,

Matt

Sorted it eventually, thought I'd post here with the solution in case anyone else came across the problem.

The issue turns out to be with the way you assign the key file to the build in C++. In older versions of Visual Studio the solution I adopted (adding a line to AssemblyInfo.cpp) was apparently the correct one but it's not correct in Visual Studio 2005, although it won't give you an error if you build with it. Instead you need to go to project properties, then linker, then advanced and edit the entry for key file in there. This will build a correctly signed assembly.

This is really poorly documented. Astonishingly, I only found the answer on a generic page about file building focused on C# and VB ... there's nothing about this I can see in the equivalent C++ pages!

http://msdn2.microsoft.com/en-us/library/6f05ezxy(VS.80).aspx

Cheers,

Matt

Thursday, March 22, 2012

Strongly typed datasets and XML

I am having trouble understanding strongly typed datasets and XML files. I
have the following schema:

<xs:schema id="Pages" targetNamespace="http://asdf.org/EOBEPages.xsd"
elementFormDefault="qualified"
xmlns="http://asdf.org" xmlns:mstns="http://asdf.org/EOBEPages.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="EOBEPages">
<xs:complexType>
<xs:sequence>
<xs:element name="Page">
<xs:complexType>
<xs:sequence>
<xs:element name="PageTitle" type="xs:string" />
<xs:element name="PageText" type="xs:string" />
<xs:element name="PageNumber" type="xs:integer" />
<xs:element name="NumImages" type="xs:integer" />
<xs:element name="ImagesDescription" type="xs:string" minOccurs="0"
maxOccurs="1" />
<xs:element name="ImageDefinitions">
<xs:complexType>
<xs:sequence>
<xs:element name="Description" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema
I load the xml data into the dataset no problem, and can access the "page"
info by:

myDataset.Page(index).pageTitle

, etc, but can NOT access the "ImageDefinitions", because I guess I don't
understand how. What I wanted to do is something like:

myVar = myDataset.Page(index).ImageDefinitions(index2).Des cription

but this is not part of the dataset... why? How can I get access to the
image definition descriptions based on the page index?

Thanks a bunch!

MC Ddatasets are tables with relationships. every xml complex type becomes a new
table. ImageDefinitions becomes a table which you can access.

myVar = myDataset.ImageDefinitions(index).Description

if you have a relionship setup you can access ImageDefinitions rows from
Page rows using GetChildRows

-- bruce (sqlwork.com)

"Big D" <a@.a.com> wrote in message
news:uam6WMY9DHA.1632@.TK2MSFTNGP12.phx.gbl...
> I am having trouble understanding strongly typed datasets and XML files.
I
> have the following schema:
> <xs:schema id="Pages" targetNamespace="http://asdf.org/EOBEPages.xsd"
> elementFormDefault="qualified"
> xmlns="http://asdf.org" xmlns:mstns="http://asdf.org/EOBEPages.xsd"
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
> <xs:element name="EOBEPages">
> <xs:complexType>
> <xs:sequence
> <xs:element name="Page">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="PageTitle" type="xs:string" />
> <xs:element name="PageText" type="xs:string" />
> <xs:element name="PageNumber" type="xs:integer" />
> <xs:element name="NumImages" type="xs:integer" />
> <xs:element name="ImagesDescription" type="xs:string" minOccurs="0"
> maxOccurs="1" /
> <xs:element name="ImageDefinitions">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="Description" type="xs:string" />
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:schema>
> I load the xml data into the dataset no problem, and can access the "page"
> info by:
> myDataset.Page(index).pageTitle
> , etc, but can NOT access the "ImageDefinitions", because I guess I don't
> understand how. What I wanted to do is something like:
> myVar = myDataset.Page(index).ImageDefinitions(index2).Des cription
> but this is not part of the dataset... why? How can I get access to the
> image definition descriptions based on the page index?
> Thanks a bunch!
> MC D

Tuesday, March 13, 2012

stuck and confused

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?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/

"CsharpGuy" <CsharpGuy@.discussions.microsoft.com> wrote in message
news:55B4FFAE-4544-4937-9441-7648D4B6A929@.microsoft.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?
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"));

"Karl Seguin [MVP]" wrote:

> 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/
>
> "CsharpGuy" <CsharpGuy@.discussions.microsoft.com> wrote in message
> news:55B4FFAE-4544-4937-9441-7648D4B6A929@.microsoft.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?
>
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" <CsharpGuy@.discussions.microsoft.com> wrote in message
news:03221FAC-4874-4B25-89C4-0D163F91FF30@.microsoft.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"));
>
> "Karl Seguin [MVP]" wrote:
>> 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/
>>
>>
>> "CsharpGuy" <CsharpGuy@.discussions.microsoft.com> wrote in message
>> news:55B4FFAE-4544-4937-9441-7648D4B6A929@.microsoft.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?
>>>
>>
>
like this:

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

"Karl Seguin [MVP]" wrote:

> 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" <CsharpGuy@.discussions.microsoft.com> wrote in message
> news:03221FAC-4874-4B25-89C4-0D163F91FF30@.microsoft.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"));
> > "Karl Seguin [MVP]" wrote:
> >> 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/
> >>
> >>
> >> "CsharpGuy" <CsharpGuy@.discussions.microsoft.com> wrote in message
> >> news:55B4FFAE-4544-4937-9441-7648D4B6A929@.microsoft.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?
> >> >>
> >>
> >>
>
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" <CsharpGuy@.discussions.microsoft.com> wrote in message
news:4D7E9908-E7A2-43EF-9495-9E643B23102B@.microsoft.com...
> like this:
> DataRow row = databable.NewRow();
> row["SalesAmount"] = arr[1].toString();
>
> "Karl Seguin [MVP]" wrote:
>> 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" <CsharpGuy@.discussions.microsoft.com> wrote in message
>> news:03221FAC-4874-4B25-89C4-0D163F91FF30@.microsoft.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"));
>>>>> > "Karl Seguin [MVP]" wrote:
>>> >> 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/
>> >>
>> >>
>> >> "CsharpGuy" <CsharpGuy@.discussions.microsoft.com> wrote in message
>> >> news:55B4FFAE-4544-4937-9441-7648D4B6A929@.microsoft.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?
>> >>> >>
>> >>
>> >>
>>
>>
>
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 [MVP]" wrote:

> 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" <CsharpGuy@.discussions.microsoft.com> wrote in message
> news:4D7E9908-E7A2-43EF-9495-9E643B23102B@.microsoft.com...
> > like this:
> > DataRow row = databable.NewRow();
> > row["SalesAmount"] = arr[1].toString();
> > "Karl Seguin [MVP]" wrote:
> >> 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" <CsharpGuy@.discussions.microsoft.com> wrote in message
> >> news:03221FAC-4874-4B25-89C4-0D163F91FF30@.microsoft.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"));
> >> >> >> >> > "Karl Seguin [MVP]" wrote:
> >> >> >> 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/
> >> >>
> >> >>
> >> >> "CsharpGuy" <CsharpGuy@.discussions.microsoft.com> wrote in message
> >> >> news:55B4FFAE-4544-4937-9441-7648D4B6A929@.microsoft.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?
> >> >> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
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" <CsharpGuy@.discussions.microsoft.com> wrote in message
news:5EF97DBC-4C69-4B07-A484-9A95230A8208@.microsoft.com...
>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 [MVP]" wrote:
>> 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" <CsharpGuy@.discussions.microsoft.com> wrote in message
>> news:4D7E9908-E7A2-43EF-9495-9E643B23102B@.microsoft.com...
>> > like this:
>>> > DataRow row = databable.NewRow();
>> > row["SalesAmount"] = arr[1].toString();
>>>>> > "Karl Seguin [MVP]" wrote:
>>> >> 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" <CsharpGuy@.discussions.microsoft.com> wrote in message
>> >> news:03221FAC-4874-4B25-89C4-0D163F91FF30@.microsoft.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"));
>> >>> >>> >>> >> > "Karl Seguin [MVP]" wrote:
>> >>> >> >> 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/
>> >> >>
>> >> >>
>> >> >> "CsharpGuy" <CsharpGuy@.discussions.microsoft.com> wrote in message
>> >> >> news:55B4FFAE-4544-4937-9441-7648D4B6A929@.microsoft.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?
>> >> >>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>
>>
>>
>
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:u013J8xPGHA.3016@.tk2msftngp13.phx.gbl...
> 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" <CsharpGuy@.discussions.microsoft.com> wrote in message
> news:5EF97DBC-4C69-4B07-A484-9A95230A8208@.microsoft.com...
>>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 [MVP]" wrote:
>>
>>> 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" <CsharpGuy@.discussions.microsoft.com> wrote in message
>>> news:4D7E9908-E7A2-43EF-9495-9E643B23102B@.microsoft.com...
>>> > like this:
>>>>> > DataRow row = databable.NewRow();
>>> > row["SalesAmount"] = arr[1].toString();
>>>>>>>>> > "Karl Seguin [MVP]" wrote:
>>>>> >> 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" <CsharpGuy@.discussions.microsoft.com> wrote in message
>>> >> news:03221FAC-4874-4B25-89C4-0D163F91FF30@.microsoft.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"));
>>> >>>> >>>> >>>> >> > "Karl Seguin [MVP]" wrote:
>>> >>>> >> >> 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/
>>> >> >>
>>> >> >>
>>> >> >> "CsharpGuy" <CsharpGuy@.discussions.microsoft.com> wrote in message
>>> >> >> news:55B4FFAE-4544-4937-9441-7648D4B6A929@.microsoft.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?
>>> >> >>>> >> >>
>>> >> >>
>>> >> >>
>>> >>
>>> >>
>>> >>
>>>
>>>
>>>
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/d...con_03_6mht.asp

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

"CsharpGuy" <me@.me.com> wrote in message
news:e7jOI55PGHA.2108@.TK2MSFTNGP10.phx.gbl...
>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:u013J8xPGHA.3016@.tk2msftngp13.phx.gbl...
>> 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" <CsharpGuy@.discussions.microsoft.com> wrote in message
>> news:5EF97DBC-4C69-4B07-A484-9A95230A8208@.microsoft.com...
>>>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 [MVP]" wrote:
>>>
>>>> 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" <CsharpGuy@.discussions.microsoft.com> wrote in message
>>>> news:4D7E9908-E7A2-43EF-9495-9E643B23102B@.microsoft.com...
>>>> > like this:
>>>>>>> > DataRow row = databable.NewRow();
>>>> > row["SalesAmount"] = arr[1].toString();
>>>>>>>>>>>>> > "Karl Seguin [MVP]" wrote:
>>>>>>> >> 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" <CsharpGuy@.discussions.microsoft.com> wrote in message
>>>> >> news:03221FAC-4874-4B25-89C4-0D163F91FF30@.microsoft.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"));
>>>> >>>>> >>>>> >>>>> >> > "Karl Seguin [MVP]" wrote:
>>>> >>>>> >> >> 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/
>>>> >> >>
>>>> >> >>
>>>> >> >> "CsharpGuy" <CsharpGuy@.discussions.microsoft.com> wrote in
>>>> >> >> message
>>>> >> >> news:55B4FFAE-4544-4937-9441-7648D4B6A929@.microsoft.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?
>>>> >> >>>>> >> >>
>>>> >> >>
>>>> >> >>
>>>> >>
>>>> >>
>>>> >>
>>>>
>>>>
>>>>
>>
>>

stuck and confused

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 th
e
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?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/
"CsharpGuy" <CsharpGuy@.discussions.microsoft.com> wrote in message
news:55B4FFAE-4544-4937-9441-7648D4B6A929@.microsoft.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?
>
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"));
"Karl Seguin [MVP]" wrote:

> 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/
>
> "CsharpGuy" <CsharpGuy@.discussions.microsoft.com> wrote in message
> news:55B4FFAE-4544-4937-9441-7648D4B6A929@.microsoft.com...
>
>
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" <CsharpGuy@.discussions.microsoft.com> wrote in message
news:03221FAC-4874-4B25-89C4-0D163F91FF30@.microsoft.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"));
>
> "Karl Seguin [MVP]" wrote:
>
like this:
DataRow row = databable.NewRow();
row["SalesAmount"] = arr[1].toString();
"Karl Seguin [MVP]" wrote:

> 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" <CsharpGuy@.discussions.microsoft.com> wrote in message
> news:03221FAC-4874-4B25-89C4-0D163F91FF30@.microsoft.com...
>
>
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" <CsharpGuy@.discussions.microsoft.com> wrote in message
news:4D7E9908-E7A2-43EF-9495-9E643B23102B@.microsoft.com...
> like this:
> DataRow row = databable.NewRow();
> row["SalesAmount"] = arr[1].toString();
>
> "Karl Seguin [MVP]" wrote:
>
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 [MVP]" wrote:

> well...so far everything looks ok...
> can you put a breakpoint and see what format arr[1] is in. My guess is tha
t
> 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" <CsharpGuy@.discussions.microsoft.com> wrote in message
> news:4D7E9908-E7A2-43EF-9495-9E643B23102B@.microsoft.com...
>
>
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" <CsharpGuy@.discussions.microsoft.com> wrote in message
news:5EF97DBC-4C69-4B07-A484-9A95230A8208@.microsoft.com...
>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 [MVP]" wrote:
>
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:u013J8xPGHA.3016@.tk2msftngp13.phx.gbl...
> 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" <CsharpGuy@.discussions.microsoft.com> wrote in message
> news:5EF97DBC-4C69-4B07-A484-9A95230A8208@.microsoft.com...
>
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/d... />
3_6mht.asp
Karl
--
http://www.openmymind.net/
"CsharpGuy" <me@.me.com> wrote in message
news:e7jOI55PGHA.2108@.TK2MSFTNGP10.phx.gbl...
>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:u013J8xPGHA.3016@.tk2msftngp13.phx.gbl...
>