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


C# SQLiteCommand.ExecuteStatement方法代码示例

本文整理汇总了C#中System.Data.SQLite.SQLiteCommand.ExecuteStatement方法的典型用法代码示例。如果您正苦于以下问题:C# SQLiteCommand.ExecuteStatement方法的具体用法?C# SQLiteCommand.ExecuteStatement怎么用?C# SQLiteCommand.ExecuteStatement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.SQLite.SQLiteCommand的用法示例。


在下文中一共展示了SQLiteCommand.ExecuteStatement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadpVm

		internal void ReadpVm (Sqlite3.Vdbe pVm, int version, SQLiteCommand cmd)
		{
			int pN;
			IntPtr pazValue;
			IntPtr pazColName;
			bool first = true;
			
			DeclaredMode[] declmode = null;

			while (true) {
				bool hasdata = cmd.ExecuteStatement(pVm, out pN, out pazValue, out pazColName);
			
				// For the first row, get the column information
				if (first) {
					first = false;
					
					if (version == 3) {
						// A decltype might be null if the type is unknown to sqlite.
						decltypes = new string[pN];
						declmode = new DeclaredMode[pN]; // 1 == integer, 2 == datetime
						for (int i = 0; i < pN; i++) {
							string decl = Sqlite3.sqlite3_column_decltype (pVm, i);
							if (decl != null) {
								decltypes[i] = decl.ToLower(System.Globalization.CultureInfo.InvariantCulture);
								if (decltypes[i] == "int" || decltypes[i] == "integer")
									declmode[i] = DeclaredMode.Integer;
								else if (decltypes[i] == "date" || decltypes[i] == "datetime")
									declmode[i] = DeclaredMode.DateTime;
								else if(decltypes[i] == "uniqueidentifier" || decltypes[i] == "guid")
									declmode[i] = DeclaredMode.Guid;
							}
						}
					}
					
					columns = new string[pN];	
					for (int i = 0; i < pN; i++) {
						string colName;
						//if (version == 2) {
						//	IntPtr fieldPtr = Marshal.ReadIntPtr (pazColName, i*IntPtr.Size);
						//	colName = Sqlite.HeapToString (fieldPtr, ((SqliteConnection)cmd.Connection).Encoding);
						//} else {
							colName = Sqlite3.sqlite3_column_name (pVm, i);
						//}
						columns[i] = colName;
						column_names_sens [colName] = i;
						column_names_insens [colName] = i;
					}
				}

				if (!hasdata) break;
				
				object[] data_row = new object [pN];
				for (int i = 0; i < pN; i++) {
				switch (Sqlite3.sqlite3_column_type (pVm, i)) {
					case 1:
						long val = Sqlite3.sqlite3_column_int64 (pVm, i);
					
						// If the column was declared as an 'int' or 'integer' OR the type of column is unknown
						// let's play nice and return an int (version 3 only).
						if ((declmode[i] == DeclaredMode.Integer || decltypes[i] == null) && val >= int.MinValue && val <= int.MaxValue)
							data_row[i] = (int)val;
						
						// Or if it was declared a date or datetime, do the reverse of what we
						// do for DateTime parameters.
						else if (declmode[i] == DeclaredMode.DateTime)
							data_row[i] = DateTime.FromFileTime(val);								
						else
							data_row[i] = val;
							
						break;
					case 2:
						data_row[i] = Sqlite3.sqlite3_column_double (pVm, i);
						break;
					case 3:
						data_row[i] = Sqlite3.sqlite3_column_text (pVm, i);
						
						// If the column was declared as a 'date' or 'datetime', let's play
						// nice and return a DateTime (version 3 only).
						if (declmode[i] == DeclaredMode.DateTime)
							if (data_row[i] == null) data_row[i] = null;
							else data_row[i] = DateTime.Parse((string)data_row[i], System.Globalization.CultureInfo.InvariantCulture);
						else if (declmode[i] == DeclaredMode.Guid){
							Guid g;
							if (data_row[i] == null) data_row[i] = null;
							else if (Guid.TryParse((string)data_row[i], out g)) data_row[i] = g;
						}
						break;
					case 4:
						byte[] blob = Sqlite3.sqlite3_column_blob(pVm, i);
						data_row[i] = blob;
						break;
					case 5:
						data_row[i] = null;
						break;
					default:
						throw new Exception ("FATAL: Unknown sqlite3_column_type");
					}
				}
				rows.Add (data_row);
			}
//.........这里部分代码省略.........
开发者ID:jcwmoore,项目名称:athena,代码行数:101,代码来源:SQLiteDataReader.cs


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