我创建了像server exploler/data connection/add connection 这样的数据库。 Microsoft SQL Server Compact 3.5 (.NET Framework) 使用 Create 并创建我自己的 MyDatabes.sdf 文件。
现在在 server explorer 中右键单击我的数据库 --- 然后单击 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])
)
按下执行查询:
它显示表查询定义不同,写的地方
“不支持 CREATE TABLE SQL 构造或语句。”
点击继续
显示 SQL 执行错误
“错误源:SQL Server Compact ADO.NET 数据提供程序错误消息:指定的数据类型无效。[数据类型(如果已知)=Varchar]”;
我希望查询没问题...我希望 ADO、NET 知道 Varchar。请问你知道这是问题吗?
使用 Visual Studio 2010 Ultimate。
最佳答案
varchar(n)
是 indeed not supported on CE ;只有 unicode nvarchar(n)
、nchar(n)
和 ntext
。更改为 nvarchar(10)
、nvarchar(5)
和 nchar(1)
等
还有;从最简单的可行操作(表等)开始 - 并不断扩展它直到它中断,然后您就会知道哪些位失败了。
关于c# - 在 Visual Studio 中执行查询时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6242861/