在Visual Studio执行查询时出现错误出现错误、Visual、Studio

2023-09-03 01:38:43 作者:牽手dé約定

我喜欢创造的服务器exploler / 数据连接 / 添加连接databese 的。 Microsoft SQL Server压缩3.5(.NET框架)的使用的创建的,并创建自己的 MyDatabes.sdf 的文件。

I created databese like server exploler/ data connection / add connection . Microsoft SQL Server Compact 3.5 (.NET Framework) use Create and create my own MyDatabes.sdf file.

现在的服务器exploler 的右键点击我的databese ---并点击新的查询的

Now in server exploler right click on my databese --- and click on new query

尝试运行此:

Create table [student]
(
    [student_id] Bigint NOT NULL,
    [bornnumber] Varchar(10) NOT NULL,
    [branch] Integer NOT NULL,
    [specialization] Integer NOT NULL,
    [year] Smallint NULL,
    [studygroup] Varchar(5) NOT NULL,
    [started] Datetime NULL,
    [finished] Datetime NULL,
    [status] Char(1) NULL,
Primary Key ([student_id])
) 

preSS执行查询:

press execute query:

就说明表的查询定义不同wher写入

it shows table Query Definitions Differ wher is written

使用CREATE TABLE SQL构造或语句不支持。

"The CREATE TABLE SQL construct or statement is not supported."

点击conntinnous

Click to conntinnous

显示SQL Executation错误

Shows SQL Executation ERROR

错误源:SQL Server压缩ADO.NET数据提供程序错误消息:指定的数据类型无效[数据类型(如果知道)=的Varchar];

"Error Source: SQL Server Compact ADO.NET Data PRovider Error Message: The specified data type is not valid.[Data type (if known)=Varchar]";

我希望查询是好的......我希望ADO,NET知道VARCHAR。请你知道,我们是什么问题?

I hope query is fine... and I hope ADO,NET know Varchar. Please Do you know were is problem ?

使用Visual Studio 2010旗舰版。

using Visual Studio 2010 Ultimate.

推荐答案

VARCHAR(n)的是的确实不支持在CE ;只有单向code 为nvarchar(N)的nchar(N) NTEXT 。更改为为nvarchar(10)为nvarchar(5)的nchar(1)等。

varchar(n) is indeed not supported on CE; only unicode nvarchar(n), nchar(n) and ntext. Change to nvarchar(10), nvarchar(5) and nchar(1), etc.

此外,从最简单的操作(表等)的作品 - 而且不断扩大它,直到它打破,那么你就会知道哪个位失败

Also; start with the simplest operation (table etc) that works - and keep expanding it until it breaks, then you'll know which bits fail.