Solved

Strange File Creation Error

Posted on 2007-04-03
2
231 Views
Last Modified: 2010-04-16
Hi,

I read a CSV file and use a string builder to compile a large string. I have used this for speed.

Once it has built the entire string of 60,000 rows, I write this to a file, I call, BULKLINES.sql

OK, I then have an sql stored procedure which is BULK INSERT, and points to that file. HERE is the wierd part.

When I execute the stored procedure on the file I created it errors, BUT if I open the file with notepad, CTRL-A select all and copy to a new file, lets say BULKLINES_COPY.sql and then run the stored procedure pointing at this copied file, it works great.

I cannot pinpoint the error as the two files are the same with regards to their contents. But yet it will onky work on the copy file.

Could I be writing the file wrong?  I simply use a streamWriter and I have tried the WriteLine and Write Methods

Thanks in advance

Andrew
0
Comment
Question by:REA_ANDREW
2 Comments
 
LVL 20

Author Comment

by:REA_ANDREW
ID: 18842371
Thye error I receive is this

Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 1, column 1 (ID).
0
 
LVL 5

Accepted Solution

by:
mzalewski earned 500 total points
ID: 18847616
Try using ASCII Encoding instead:

new StreamWriter(fileName, true, System.Text.Encoding.ASCII);
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Replace &lt; with < 14 59
FTP file download using c# 3 23
Winform Module - What is the ASP.Net equiv 2 23
Release Dynamically Allocated Memory in C# 3 27
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question