本文整理汇总了C#中System.Data.SQLite.SQLiteCommand.GetName方法的典型用法代码示例。如果您正苦于以下问题:C# SQLiteCommand.GetName方法的具体用法?C# SQLiteCommand.GetName怎么用?C# SQLiteCommand.GetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SQLite.SQLiteCommand
的用法示例。
在下文中一共展示了SQLiteCommand.GetName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Query
private static string Query(string query)
{
var report = "";
if(MODE == DBMODE.SQLITE) {
//then actually do it
if(currentDatabaseName.Length > 0) {
var conn = new SQLiteConnection(string.Format("Data Source={0};Version=3;", currentDatabaseName));
conn.Open();
IDataReader results = null;
string errorText = string.Empty;
try{
results = new SQLiteCommand(query, conn).ExecuteReader();
}catch(Exception e) {
errorText = e.Message;
}
if(results != null) {
//i must keep the same order. i could do dict int, dict name type... but meah
var columns = new string[results.FieldCount];
var columnTypes = new Type[results.FieldCount];
for(int i=0; i < results.FieldCount; ++i) {
columns[i] = results.GetName(i);
columnTypes[i] = results[columns[i]].GetType();
}
DataTable table = null;
while(results.Read()) {
if(table == null) {
table = new DataTable(columns, columnTypes);}
var row = new DataRow();
foreach(string columnName in columns) {
row[columnName] = results[columnName];}
if(table != null) {
table.AddRow(row);}
}
if(table != null){
report = table.ToString();
}else{
report = results.RecordsAffected + " rows affected";}
}else{
report = errorText;}
conn.Close();
}else{
report = "you need to select a database before you can execute a command. use \\u your_database_name";
}
}else{
report = "currently only supporting sqlite mode...";
}
return report;
}