
Element type "SqlMap" must be declared
SqlMapConfigxml中未配置sql映射文件<sqlMap resource="xml"/>
SAP 的编程语言ABAP中,
当你创建一个数据库table的时候table 中的字段定义有两种方式
一种是直接输入字段的数据类型,大小,描述
另一种方式就是参考data element,
而data element中预定义了 数据类型, 大小, 长文本,短文本这些东西,
如果一个数据库field 参考data elemeent创建,那个data element 中的这些定义就会自动带过来
所以data element的作用总结为 为数据库字段提供模板
需要在本地先开一个服务器。
如果想在本地使用Element-UI,你需要在本地开启一个服务器。这是因为Element-UI是一个基于 Vuejs 开发的前端UI框架,它需要通过>
documentgetElementById()styldisplay='none'
getElementById()不显示。
documentgetElementById()styldisplay=''
getElementById()就显示出来
Sqlite数据库,在很多场合已经用得比较多,由于我的代码生成工具的需要,需要把Sqlite的表、字段、视图等信息获取出来,以便实现各种数据库快速生成项目工程的 *** 作。这里就需要利用C#获取Sqlite数据库的元数据了,和其他数据库一样。
为了获取Sqlite的数据库对象数据,我做了一个测试的例子来获取他的相关信息,其实它的元数据还是和Access的 *** 作方式很接近。首先我们先通过Sqlite的数据库管理工具或者Visual Studio来打开创建一些表。
首先我们先来看看通过C#代码获取到数据库对象的 *** 作界面。
获取表的元数据界面效果如下所示,视图和这个也查不多,很有意思的一点,就是它把创建的脚本的显示出来了,呵呵。
获取的表字段信息效果如下所示。
有了这些数据,我就很方便在我的代码生成工具Database2Sharp里面实现代码生成 *** 作了。
现在我们来看看以上实现的后台代码是如何的,来了解Sqlite的数据库获取元数据的 *** 作。
string connectionString = "";
public Form1()
{
InitializeComponent();
connectionString = stringFormat(@"Data Source={0}\OrderWaterdb;Version=3;", ApplicationStartupPath);
}
private void btnGetSchema_Click(object sender, EventArgs e)
{
using (SQLiteConnection conn = new SQLiteConnection(connectionString))
{
connOpen();
DataTable schemaTable = connGetSchema("TABLES");
thisdataGridView1DataSource = schemaTable;
}
}
获取表字段的 *** 作代码如下所示。
private void btnGetColumns_Click(object sender, EventArgs e)
{
using (SQLiteConnection conn = new SQLiteConnection(connectionString))
{
connOpen();
DataTable table = connGetSchema("TABLES");
if (table != null && tableRowsCount > 0)
{
string tableName = tableRows[0]["TABLE_NAME"]ToString();
DataTable schemaTable = GetReaderSchema(tableName, conn);
thisdataGridView1DataSource = schemaTable;
}
}
}
private DataTable GetReaderSchema(string tableName, SQLiteConnection connection)
{
DataTable schemaTable = null;
IDbCommand cmd = new SQLiteCommand();
cmdCommandText = stringFormat("select from [{0}]", tableName);
cmdConnection = connection;
using (IDataReader reader = cmdExecuteReader(CommandBehaviorKeyInfo | CommandBehaviorSchemaOnly))
{
schemaTable = readerGetSchemaTable();
}
return schemaTable;
}
为了实现和我代码生成工具中的数据库字段信息绑定,需要通过获取设置Sqlite的属性为对应的ColumnInfo对象,如下所示。
using (SQLiteConnection conn = new SQLiteConnection(ConnectString))
{
connOpen();
DataTable schemaTable = GetReaderSchema(tableName, conn);
foreach (DataRow dr in schemaTableRows)
{
ColumnInfo info = new ColumnInfo();
infoName = new NameElement(dr["ColumnName"]ToString());
infoOrdinal = ConvertToInt32(dr["ColumnOrdinal"]ToString());
infoAllowDBNull = (bool)dr["AllowDBNull"];
infoMaxLength = ConvertToInt32(dr["ColumnSize"]ToString());
infoDataTypeId = ConvertToInt32(dr["ProviderType"]ToString());
infoDataType = dr["DataTypeName"]ToString()Trim();
infoAutoIncrement = (bool)dr["IsAutoIncrement"];
infoIsPrimaryKey = (bool)dr["IsKey"];
infoUnique = (bool)dr["IsUnique"];
infoIsReadOnly = (bool)dr["IsReadOnly"];
string netType = dr["DataType"]ToString();
listAdd(infoNameNameToString(), info);
}
connClose();
}
代码生成工具中,这些数据库的元数据实体类信息是可以提供访问的,方便我们定制代码生成工具的模板,代码生成工具关于这些数据库对象的帮助如下所示。
这样,在代码生成工具中,就可以利用Sqlite的数据库对象数据,来生成和Oracle数据库、SqlServer数据库、Access数据库、MySql等数据库一样的项目工程代码了,获取甚至可以在自定义的模板代码模块中,添加自己的处理逻辑。
快速生成的代码如下所示。
本文通过介绍获取Sqlite的数据库元数据库,并在代码生成工具中的应用为例,给大家提供一个使用元数据进行程序开发的一个思路,希望大家可以同这种方式实现更多自定义模板或者逻辑的引用。
以上就是关于用ibatis连接数据库遇到这样的问题怎么解决全部的内容,包括:用ibatis连接数据库遇到这样的问题怎么解决、sap 中 dataelement 做什么作用、element-ui需要打开服务器等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)