[英]Error creating table in MySQL database using C#
This error occurs whenever i'm trying to run my program.每当我尝试运行我的程序时都会发生此错误。
Additional information: You have an error in your SQL syntax;
附加信息:您的 SQL 语法有错误; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
检查与您的 MySQL 服务器版本相对应的手册,以获取在第 1 行的“)”附近使用的正确语法
The code is as follows:代码如下:
private void create_Click(object sender, EventArgs e)
{
string MyConnectionString = "Server=x.x.x.x;Database=groupdes_New;Uid=root;Pwd=password;";
//create connection
MySqlConnection connection = new MySqlConnection(MyConnectionString);
//connect to database
connection.Open();
MySqlCommand cmd;
cmd = connection.CreateCommand();//create command
cmd.CommandText = "CREATE Table Newtable (" + "name" + ")";
cmd.ExecuteNonQuery();
if (connection.State == ConnectionState.Open)
{
connection.Close();
}
}
I still can't manage to solve this error.我仍然无法解决这个错误。 Thanks for the help!
谢谢您的帮助!
Your create table sintaxis is wrong.您的创建表 sintaxis 是错误的。
You need define field datatype您需要定义字段数据类型
CREATE TABLE Table1
(`myDate` datetime)
;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.