Error with executing query in visual studio

爷,独闯天下 提交于 2019-11-28 09:15:00

问题


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.

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

.

Try run this:

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 execute query:

  1. it shows table Query Definitions Differ wher is written

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

    Click to conntinnous

  2. Shows SQL Executation ERROR

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

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

using Visual Studio 2010 Ultimate.


回答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.



来源:https://stackoverflow.com/questions/6242861/error-with-executing-query-in-visual-studio

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