/// <summary>
/// 判断表中某个字段是否存在
/// </summary>
/// <param name="fieldName">字段名</param>
/// <param name="tableName">表名</param>
/// <returns></returns>
bool isExistField(string fieldName,string tableName)
{
string sql = "select sql from sqlite_master where tbl_name = '" + tableName + "' and type = 'table'";
List<Record> list = new List<Record>();
//开始查询数据库
bool r = false;
SQLiteCommand command = new SQLiteCommand(sql, _dbConnection);
SQLiteDataReader reader = command.ExecuteReader();
while (reader.Read())
{
r = reader["sql"].ToString().Contains(fieldName);
NLog.LogManager.GetCurrentClassLogger().Trace("sql=" + reader["sql"].ToString());
break;
}
reader.Close();
return r;
}
sqlite 判断表字段是否存在
最新推荐文章于 2024-02-22 18:50:56 发布