|
Hi,
I have developed a rountine that builds a string using the StringBuilder class and then creates a CSV file from the string. The CSV file is then used to import data into another application. However, after creating the CSV file there is BOM at the start of the file which is preventing me from importing into the 3rd party application.
My question is how can I create the CSV file without the BOM?
Thanks for your time.
|
|
|
|
|
Can you please post some code snippets (like creating this string by your StringBuilder, writing the CSV file, ...), cause I never heard of such a strange behaviour.
Greetings
Covean
|
|
|
|
|
BOM will only appear if you have put it there.
Definitely need to see code to work out where it is being generated.
|
|
|
|
|
Thanks both of you but I have resolved it. I was using:
Dim outFile As IO.StreamWriter = My.Computer.FileSystem.OpenTextFileWriter(csvFile, False)
which was creating the file as UFT-8 which seemd to insert the BOM. I have changed it to:
Dim outFile As IO.StreamWriter = My.Computer.FileSystem.OpenTextFileWriter(csvFile, False, System.Text.Encoding.ASCII)
which doesn't insert the BOM.
Thanks for your time.
|
|
|
|
|
As you discovered there is a difference between UTF-8 and ASCII. UTF-8 files always have the header 0xEF 0xBB 0xBF so any program reading text files should check for this and not just assume the content is pure ASCII. C# programs tend to handle this automatically in most cases.
MVP 2010 - are they mad?
|
|
|
|
|
Another lesson learned
Thanks
|
|
|
|
|
Liqz wrote: Another lesson learned
Same here, I learned it the hard way ...
MVP 2010 - are they mad?
|
|
|
|
|
At work I use Access, and have no problem attaching an Access DB to my projects, but I wish to use Open Office Base as my data source, for reasons of cheapness (I am mean!).
How can I attach this to my project in VB?
I open Data Source Configuration Wizard and am presented with Access, SQL Server Compact or SQL Server Database.
Before I go wasting my time, any advice?
Or am I stuck with Access?
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
|
|
|
|
|
Dalek Dave wrote: my project in VB
you're not just cheap.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
Hey, unfair, my home stuff is c#!
Work demands mean VB, cut me some slack
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
|
|
|
|
|
Dalek Dave wrote: Work demands mean VB ...
And I was told VB = RIP[^] except maybe in developing countries?
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
Dalek Dave wrote: At work I use Access, and have no problem attaching an Access DB to my projects, but I wish to use Open Office Base as my data source, for reasons of cheapness (I am mean!).
How can I attach this to my project in VB?
Not as easy as you'd expect from a database; AFAIK, there's no free ODBC driver. One option is to unzip the *.odb file and access it's contents directly. I'm not sure whether this can be accessed using SharpHSQL[^].
Dalek Dave wrote: Before I go wasting my time, any advice?
Or am I stuck with Access?
Depending on your needs, I'd say go for Access. You can distribute the database without paying royalties. If you need to display the embedded reports or forms, then you can distribute the Access Runtime[^] - somewhat similar to the Word-viewer.
If you don't need the reports, the forms or sprocs, then go for either Sqlite or SqlCe.
I are Troll
|
|
|
|
|
Thanks Eddy.
I think the Sqlite is probably the answer here, just means more coding for my good self.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
|
|
|
|
|
Hi,
I have created a service application in vb.net. This service get records from MS-Access database and send mail to particular user.
I have tested this service in 5 machine. In 3 Machine it is working fine. but in two machine it is throwing Exception which is below.
Exception : "The provider could not determine the Object value. For example, the row was just created, the default for the Object column was not available, and the consumer had not yet set a new Object value."
I am confused. can any one guide me where i am wrong.
Thanks in advance.
Regards
Dharmchand Dhingra
|
|
|
|
|
It would appear that you're trying to read a value that doesn't exist in a field yet. You'll have to step through the code to find out what's going on.
I'd start looking for places where you assume a value is being returned when, in fact, there's nothing there.
Truthfully, without seeing the code that throws the error, it's impossible to pinpoint a cause.
|
|
|
|
|
hi freinds
i want to build a setup project and i need to add msde to my project. i find an article in microsoft :
[]http://support.microsoft.com/kb/325004[^]
in paragraph 7-a writed : On the Build menu in the Microsoft Development Environment window, click Batch Build
but i cant find Batch Build in Build menu...
can you help me???
M.Alizadeh
|
|
|
|
|
Did you follow the example to make your project?
Batch build will only appear when the solution configurations allows such an operation. Otherwise it is not visible.
|
|
|
|
|
My question is why you're using MSDE when it's no longer supported?
The current replacement would be SQL Servedr 2008 Express Edition, which is free, from here[^].
|
|
|
|
|
Hi all,
modified 28-Nov-12 7:37am.
|
|
|
|
|
You already use IndexOf("_DIA") to get the position of the first undersocre
And use LastIndexOf(".") => get the position of the dot.
And fill with (text.LastIndexOf(".") - text.IndexOf("_DIA")) blank spaces.
Hope it helps.
|
|
|
|
|
From the sounds of things there are 2 known conditions;
1) the text to remove always starts _DIA (but may have additional numbers after)
2) #1 is always followed by .PRT
If this is the case, i would
1) get the index of #1
2) get the index of #2
4) remove this substring
5) insert a substring with padded space of length = to difference of the 2 indexes at the index found at #2
|
|
|
|
|
Thanks for ur reply.
I know to find the difference, but not able to insert padded spaces of the difference.
Any help on it will be helpful.
Thanks.
|
|
|
|
|
Here is a simple function that does what you want;
Private Function fixElement(ByVal theStringToFix As String) As String
Dim theString As String = theStringToFix
Dim diaPos As Integer
Dim prtPos As Integer
diaPos = theString.IndexOf("_DIA")
prtPos = theString.IndexOf(".PRT")
If diaPos > 0 Then
Dim padString As String = String.Empty
padString = padString.PadRight(prtPos - diaPos, " ")
theString = theString.Remove(diaPos, prtPos - diaPos)
theString = theString.Insert(diaPos + 4, padString)
End If
Return theString
End Function
|
|
|
|
|
|
Don't see why not, BUT, you want to trust my function?
you had better test it to death then!
If it were me, i would be extending the function to ensure it handle 0 zero length input string and some other conditions.
I threw the function together to show you one method of achieving the text removal, and padding compensation.
Also, as it looks like this will be running many times on an input file, i would be switching the output to a stringbuilder rather than lots of "&" operations.
|
|
|
|