C# Mysql 创建一个带空格的 table 名称
C# Mysql create a table name with spaces
我已经搜索了很多但运气不好,我的问题很简单,我有一个 class 看起来像这样:
public static void Mysql_CreateTable(string tableSegment, string ConString)
{
string strCreate = "CREATE TABLE " + tableSegment + " (CVR text,Navn text, Firma text, Nummer text, Addresse text, Postnr text, Bynavn text, Noter text, Email text, LastCallDato text, NextCallDato text, CallStatus text, MailSendt text, UniqueID text);";
using (MySqlConnection conDatabase = new MySqlConnection(ConString))
{
using (MySqlCommand cmdDatabase = new MySqlCommand(strCreate, conDatabase))
{
conDatabase.Open();
cmdDatabase.ExecuteNonQuery();
conDatabase.Close();
}
}
}
当 table 段包含这样的 space "table 1" 我收到 Mysql 错误提示:
您的 sql 语法有误;查看与您的 mysql 服务器版本对应的手册以了解正确的语法……
所以,我做错了什么?为什么我不能在 table 名称中输入 space?
这样做:
string strCreate = "CREATE TABLE `" + tableSegment + "` (CVR..............
我已经搜索了很多但运气不好,我的问题很简单,我有一个 class 看起来像这样:
public static void Mysql_CreateTable(string tableSegment, string ConString)
{
string strCreate = "CREATE TABLE " + tableSegment + " (CVR text,Navn text, Firma text, Nummer text, Addresse text, Postnr text, Bynavn text, Noter text, Email text, LastCallDato text, NextCallDato text, CallStatus text, MailSendt text, UniqueID text);";
using (MySqlConnection conDatabase = new MySqlConnection(ConString))
{
using (MySqlCommand cmdDatabase = new MySqlCommand(strCreate, conDatabase))
{
conDatabase.Open();
cmdDatabase.ExecuteNonQuery();
conDatabase.Close();
}
}
}
当 table 段包含这样的 space "table 1" 我收到 Mysql 错误提示:
您的 sql 语法有误;查看与您的 mysql 服务器版本对应的手册以了解正确的语法……
所以,我做错了什么?为什么我不能在 table 名称中输入 space?
这样做:
string strCreate = "CREATE TABLE `" + tableSegment + "` (CVR..............