Solved

Strange File Creation Error

Posted on 2007-04-03
2
235 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

679 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