本文整理汇总了C#中System.Data.SQLite.SQLiteCommand.GetOrdinal方法的典型用法代码示例。如果您正苦于以下问题:C# SQLiteCommand.GetOrdinal方法的具体用法?C# SQLiteCommand.GetOrdinal怎么用?C# SQLiteCommand.GetOrdinal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SQLite.SQLiteCommand
的用法示例。
在下文中一共展示了SQLiteCommand.GetOrdinal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAction
internal Action GetAction(string actionName)
{
var cn = new SQLiteConnection("Data Source=" + DbName + ";Version=3;");
cn.Open();
var reader = new SQLiteCommand("select id, command, arg1, arg2 from actions where id = '" + actionName + "'", cn).ExecuteReader();
Action action = null;
try
{
if (reader.Read())
{
action = new Action();
action.Id = reader.GetString(reader.GetOrdinal("id"));
action.Arg1 = reader.GetString(reader.GetOrdinal("arg1"));
var arg2 = reader["arg2"];
action.Arg2 = arg2.ToString();
//action.Arg3 = reader.GetString(reader.GetOrdinal("arg3"));
if (reader.GetString(reader.GetOrdinal("command")) == "pgdb-backup")
{
action.Command = new PostgreSQLBackupCommand(action.Arg1, action.Arg2, action.Arg3, action.Arg4);
}
if (reader.GetString(reader.GetOrdinal("command")) == "execute-bat")
{
action.Command = new ExecuteBatCommand(action.Arg1);
}
if (reader.GetString(reader.GetOrdinal("command")) == "sync-actions")
{
action.Command = new SyncActionsCommand(action.Arg1);
}
}
}
finally
{
cn.Close();
}
return action;
}
示例2: ApplicationControl_Load
private void ApplicationControl_Load(object sender, EventArgs e)
{
#region read
var csb = new SQLiteConnectionStringBuilder
{
DataSource = DataSource,
Version = 3
};
using (var c = new SQLiteConnection(csb.ConnectionString))
{
c.Open();
{
var sql = "create table if not exists Table1 (ContentKey INTEGER PRIMARY KEY AUTOINCREMENT, ContentValue text not null, ContentBytes blob)";
using (var reader = new SQLiteCommand(sql, c).ExecuteReader())
{
}
}
{
var sql = "select ContentValue, ContentBytes from Table1";
var cmd = new SQLiteCommand(sql, c);
using (var reader = cmd.ExecuteReader())
{
while (reader.Read())
{
var ContentValue = reader.GetString(reader.GetOrdinal("ContentValue"));
var chunkSize = 4096;
// Get size of image data–pass null as the byte array parameter
long bytesize = reader.GetBytes(reader.GetOrdinal("ContentBytes"), 0, null, 0, 0);
// Allocate byte array to hold image data
byte[] imageData = new byte[bytesize];
long bytesread = 0;
int curpos = 0;
while (bytesread < bytesize)
{
// chunkSize is an arbitrary application defined value
bytesread += reader.GetBytes(reader.GetOrdinal("ContentBytes"), curpos, imageData, curpos, chunkSize);
curpos += chunkSize;
}
dataGridView1.Rows.Add(
"",
ContentValue,
"" + bytesize
);
}
}
}
}
#endregion
}