Solved

Strange File Creation Error

Posted on 2007-04-03
2
237 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
itextsharp with c# 3 35
Set custom font WPF 2 26
c#, datatable, aspx 4 53
Windows Universal App 22 63
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

751 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