我不断收到此错误数据库架构已更改为“1”附近:语法错误.我没有在代码中更改我的架构.这是我制作架构的代码.希望尝试每个答案,以便您发布它.此代码用于将数据库传输到另一个数据库程序.因此它必须与多个数据库程序...

我不断收到此错误数据库架构已更改为“1”附近:语法错误.
我没有在代码中更改我的架构.
这是我制作架构的代码.
希望尝试每个答案,以便您发布它.
此代码用于将数据库传输到另一个数据库程序.
因此它必须与多个数据库程序兼容.
public DataTable GetSchemaTable(string schema, string nameTable)
{
switch (m_dbType)
{
case dbTypeEnum.Sqlite:
//Make the schema of the source table
MakeConnectionString();
string fullTableName = schema.Length > 0
? string.Format("[{0}].[{1}]", schema, nameTable)
: string.Format("[{0}]", nameTable);
if (!string.IsNullOrEmpty(fullTableName))
{
string sql = string.Format("SELECT * FROM {0} LIMIT 1", fullTableName);
DataTable dtSchemaSource;
try
{
using (IDataReader rdr = ReadOnlyForwardOnly(sql))
{
dtSchemaSource = rdr.GetSchemaTable();
}
}
finally
{
CloseConnection();
}
if (dtSchemaSource == null)
{
throw new RadGeneralException("rdr.GetSchemaTable() returns null with sql = " + sql);
}
return dtSchemaSource;
}
break;
default:
//Make the schema of the source table
MakeConnectionString();
string fullTableName = schema.Length > 0
? string.Format("[{0}].[{1}]", schema, nameTable)
: string.Format("[{0}]", nameTable);
string sql = string.Format("SELECT TOP 1 * FROM {0}", fullTableName);
DataTable dtSchemaSource;
try
{
using (IDataReader rdr = ReadOnlyForwardOnly(sql))
{
dtSchemaSource = rdr.GetSchemaTable();
}
}
finally
{
CloseConnection();
}
if (dtSchemaSource == null)
{
throw new RadGeneralException("rdr.GetSchemaTable() returns null with sql = " + sql);
}
return dtSchemaSource;
}
}
这是sqlite架构发生更改的部分.
StringBuilder sbColList = new StringBuilder();
nCol = 0;
identityColInBothTables = false;
//Make the schema of the source table
DataTable dtSchemaSource = objDbSource.GetSchemaTable(SchemaSource, Name);
//Make the schema of the target table
DataTable dtSchemaTarget = objDbTarget.GetSchemaTable(SchemaTarget, Name);
解决方法:
我相信,而不是SELECT TOP 1 *你需要使用SELECT * FROM …. LIMIT 1
织梦狗教程
本文标题为:c# – 数据库模式已更改


基础教程推荐
猜你喜欢
- Unity Shader实现描边OutLine效果 2023-02-06
- c#如何使用 XML 文档功能 2023-03-13
- 基于多态之虚方法、抽象类、接口详解 2022-11-27
- C#使用Socket实现服务器与多个客户端通信(简单的聊天系统) 2023-02-08
- C#调用第三方工具完成FTP操作 2023-06-08
- C#使用Enum.TryParse()实现枚举安全转换 2023-06-28
- unity实现场景切换进度条显示 2023-02-02
- C# .NET中Socket简单实用框架的使用教程 2022-11-14
- 深入理解C#委托delegate的使用 2023-06-27
- C# 实现在控制台上换行输出与不换行输出 2023-04-10