Solved

Strange File Creation Error

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
.xltm file opens as .xlsx file 3 37
Image(7) 1 37
Create XML 5 34
ASP.NET Web API or ASP.NET Core MVC? 3 25
Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now