无法识别SQL数据库表类型 [英] SQL database table type not recognised

查看:88
本文介绍了无法识别SQL数据库表类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在尝试以编程方式创建一个带有表的数据库.


I''m trying to create a database with a table in it programatically.

SqlCeEngine engine = new SqlCeEngine(connStr);
engine.CreateDatabase();

SqlCeConnection conn = new SqlCeConnection(connStr);
conn.Open();

SqlCeCommand cmd = conn.CreateCommand();
cmd.CommandText = "CREATE TABLE Log(Type string,Rego float)";
cmd.ExecuteNonQuery();        



但是,当我运行它时,出现此错误:

>>指定的数据类型无效. [数据类型(如果已知)=字符串]

如果我将它们都设置为浮动,则效果很好.它也不适用于char或text.

如果有人对此事有任何想法,那将是最有帮助的.
在此先感谢



However when I run it I get this error:

>>The specified data type is not valid. [ Data type (if known) = string ]

If I set them both to float it works fine. It also doesn''t work for char or text.

If anyone has any idea on the matter it would be most helpful.
Thanks in advance

推荐答案

看看支持的类型-请参见
Have a look at supported types - see here[^]. There is no support for string or char.
Try using nchar or ntext.


创建表日志(键入文本,Rego浮动)
CREATE TABLE Log(Type text,Rego float)


SqlCeEngine engine = new SqlCeEngine(connStr);
engine.CreateDatabase();
 
SqlCeConnection conn = new SqlCeConnection(connStr);
conn.Open();
 
SqlCeCommand cmd = conn.CreateCommand();
cmd.CommandText = "CREATE TABLE Log(Type ntext,Rego float)";
cmd.ExecuteNonQuery();


这篇关于无法识别SQL数据库表类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆