Why is SQL CE Toolbox failing to parse my csv file?

匆匆过客 提交于 2019-12-11 07:18:55

问题


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?

来源:https://stackoverflow.com/questions/15330310/why-is-sql-ce-toolbox-failing-to-parse-my-csv-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!