Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
405 views
in Technique[技术] by (71.8m points)

c# - Error with executing query in visual studio

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...