当前位置: 首页>>代码示例>>C#>>正文


C# SQLiteCommand.GetOrdinal方法代码示例

本文整理汇总了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;
        }
开发者ID:cesarreyesa,项目名称:monkey,代码行数:39,代码来源:Repository.cs

示例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

        }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:57,代码来源:ApplicationControl.cs


注:本文中的System.Data.SQLite.SQLiteCommand.GetOrdinal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。