Why is SQL CE Toolbox failing to parse my csv file

2019-07-29 05:09发布

问题:

SQLCEToolbox looks very promising.

I installed it, opened VS 2012, selected Tools | SQL Server Compact Toolbox, quickly and easily set up a connection to my sdf database, which I had (also quickly and easily) created in WebMatrix.

I then right-clicked the database in SQLCEToolbox's treeview and selected Import from CSV file.

Note: One must explicitly specify the column names on the first line in the file (line/row 0) and explicitly add the ID/Primary Key/Identity vals (if you have such a column).

Once I fixed the various formatting errors with my csv file, it seemed to import well. But I got this err msg:

Error Code: 80004005
 Message   : The data was truncated while converting from one data type to another. [ Name of function(if known) =  ]
 Minor Err.: 25920
 Source    : SQL Server Compact ADO.NET Data Provider

My data is in the format:

1,SomeCategory,SomeName,SomeURL,Longitude,Latitude

As an example, here's a sample line:

3,ArtGallery, Henry Miller Memorial Library,http://www.henrymiller.org/, -121.7537834,36.2207945

Except for the int ID column, they are all nvarchar(50) columns. So I realized that some of my URLs were longer than 50 chars; so, in WebMatrix, I modified that column to be nvarchar(128). On trying again to import, apparently that first problem was solved, but now I get:

Error Code: 80004005
 Message   : The column cannot be modified. [ Column name = ID ]
 Minor Err.: 25004
 Source    : SQL Server Compact ADO.NET Data Provider
 Err. Par. : ID

Okay, I reason, since the ID column is to be automatically updated, I shouldn't have it in my csv file. So I changed it to this:

Category,Name,URL,Longitude,Latitude
ArtGallery, Henry Miller Memorial Library,http://www.henrymiller.org/, -121.7537834,36.2207945

...but when I tried importing the records that way (with "ID" removed from row 0 and the corresponding val from each line/record), and try to import, I get:

Error Code: 80004005
 Message   : The data was truncated while converting from one data type to another. [ Name of function(if known) =  ]
 Minor Err.: 25920
 Source    : SQL Server Compact ADO.NET Data Provider

I tried to post a question at http://sqlcetoolbox.codeplex.com/, but trying to do so simply took me to a generic codeplex area (rather than a SQL CE Toolbox-specific area).

So what might be the problem here (the revised row 0 and another sample row are shown below) now? The longest URL is only 98 chars.

What's wrong with my data or methodology?