查询有空格其名称中的表 [英] Query a table that has spaces in its name

查看:159
本文介绍了查询有空格其名称中的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一种情况,我有一个名为Access表的气体流量的,我想补充记录。当我尝试运行我的插入查询类似的表的常见站的,我得到以下错误:

I have a situation, I have a Access table named Gas Flow Rates that I want to add records. When I try to run my insert query for a similar table Common Station, I get the following error:

错误HY000:语法错误,查询不完整的查询子句

"error hy000: syntax error, in query incomplete query clause"

代码是:

using System;
using System.Data.Odbc;

class MainClass
{
static void Main(string[] args)
{
    string connectionString = "Dsn=Gas_meter";
    string sqlins = "";
    OdbcConnection conn = new OdbcConnection(connectionString);

    OdbcCommand cmdnon = new OdbcCommand(sqlins, conn);
    conn.Open();

    try
    {
       cmdnon.CommandText = "INSERT INTO 'Common station' ( S1Flow, S2Flow, S3Flow, S4Flow) VALUES (9999,999, 999, 999)";
        //Once the above line works replace it with cmdnon.CommandText= "INSERT INTO Gas Flow Rates ( S1Flow, S2Flow, S3Flow, S4Flow) VALUES (9999,999, 999, 999)"
        int rowsAffected = cmdnon.ExecuteNonQuery();
        Console.WriteLine(rowsAffected);
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.ToString());
    }
    finally
    {
        conn.Close();
    }
}
}



我如何克服错误?

How do I overcome that error?

推荐答案

用方括号括在间隔了项目:

Surround the spaced out item with square brackets:

[Common station]

然后就打谁设计了数据库的家伙

Then slap the guy who designed the database.

这篇关于查询有空格其名称中的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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