【问题标题】:Finisar.SQLite.SQLiteException: SQL logic error or missing database: unrecognized token: "$"Finisar.SQLite.SQLiteException:SQL 逻辑错误或缺少数据库:无法识别的令牌:“$”
【发布时间】:2017-01-09 18:03:22
【问题描述】:

我用VS2012开发了一个小小的C#/SQl应用程序,我会后悔一辈子,反正我调试完了,一切正常,悲剧来了:没有设置发布工具。所以我尝试了使用发布选项等的一键式方式,并且我已经包含了 .NET 4 框架,但是当我测试没有任何效果并且安装程序说框架丢失和其他东西时,所以回到我的实验室我改为 VS2010受益于设置能力...我做到了,对我来说,该应用程序也可以正常工作,并且安装也可以正常工作并安装了该应用程序。

现在我需要在另一台电脑上安装应用程序,但它没有我的服务器,所以我切换到 sqlite。

关于无法识别令牌的错误出现在哪里,因为我使用 sql 导入/导出向导从 excel 导入了我的数据库,并且它自动将表名写为“Archive$”,我现在无法烘焙到 xls 文件,我不知道如何在 db 文件中重命名它。这是我的问题。谢谢你帮助我。

using System.Threading.Tasks;
using System.Windows.Forms;
using System.Reflection;
using System.IO;
using System.Data.SqlClient;
using DgvFilterPopup;
using Finisar.SQLite;

namespace ExpertGeoMaster_v._1
{
    public partial class Form1 : Form
    {
        DataTable DT = new DataTable();
        DialogResult res;

        public static string p = @"C:\Users\abdellaziz\Documents\Visual Studio 2010\Projects\ExpertGeoMaster v.1\ExpertGeoMaster v.1\bin\Debug\database.db";


        public Form1()
        {
            InitializeComponent();

        }


        private void Form1_Load(object sender, EventArgs e)
        {
            using (SQLiteConnection cn = new SQLiteConnection(@"Data Source=./database.db;Version=2;New=True;Compress=True;"))
            {
                this.dataGridView1.SelectionMode =
                    DataGridViewSelectionMode.FullRowSelect;
                SQLiteDataAdapter da = new SQLiteDataAdapter(@"Select * from Archive$", cn);
                try
                {
                    cn.Open();
                    da.Fill(DT);
                    this.dataGridView1.DataSource = DT;

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                cn.Close();
            }

【问题讨论】:

  • 你用 C# 查找过 ConnectionStrings 有一个在线网站提供了如何为每种类型的数据库执行所有连接字符串的示例
  • 是的,但由于它检测到 $ 我认为它已连接到数据库并获得了对表的访问权限......不是吗??
  • 所以你有一个名为Archive$的表,如果你问我的话,命名约定很差......
  • 我为你引用了我自己:这是关于无法识别令牌的错误,因为我使用 sql 导入/导出向导从 excel 导入了我的数据库,它自动将表名写为“存档$",我现在无法烘焙到 xls 文件,而且我不知道如何在 db 文件中重命名它。这是我的问题。谢谢你帮助我。

标签: c# sql-server visual-studio-2010 sqlite


【解决方案1】:

$ 这样的特殊字符通常不允许出现在标识符中。

use quotes:

new SQLiteDataAdapter(@"Select * from \"Archive$\"", cn);
new SQLiteDataAdapter(@"Select * from [Archive$]", cn);
new SQLiteDataAdapter(@"Select * from `Archive$`", cn);

【讨论】:

  • thx 它至少更改为另一个输出,我将此作为错误:Finisar.SQLite.SQLiteException:SQL 逻辑错误或缺少数据库:没有这样的表:Archive$ à Finisar.SQLite.sqlite2.Throw (Int32 sqliteResult, IntPtr pSQLiteErrMsg) à Finisar.SQLite.sqlite2.CheckOK(Int32 sqliteResult, IntPtr pSQLiteErrMsg) à Finisar.SQLite.sqlite2.compile(String zSql) à Finisar.SQLite.OneSQLStatement.Compile() à Finisar.SQLite.SQLiteDataReader .ExecuteFirstStep() à Finisar.SQLite.SQLiteDataReader.EnsureInitialization() à Finisar.SQLite.SQLiteDataReader.get_FieldCount() à
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-01-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多