本文整理汇总了C#中Mono.Data.Sqlite.SqliteDataReader.GetDataTypeName方法的典型用法代码示例。如果您正苦于以下问题:C# SqliteDataReader.GetDataTypeName方法的具体用法?C# SqliteDataReader.GetDataTypeName怎么用?C# SqliteDataReader.GetDataTypeName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Data.Sqlite.SqliteDataReader
的用法示例。
在下文中一共展示了SqliteDataReader.GetDataTypeName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadAllRows
private void ReadAllRows (SqliteDataReader reader)
{
int ii, field_count = reader.FieldCount;
/* Metadata */
records_affected = reader.RecordsAffected;
decltypes = new string[field_count];
for (ii = 0; ii < field_count; ii++) {
decltypes[ii] = reader.GetDataTypeName (ii);
}
columns = new string[field_count];
for (ii = 0; ii < field_count; ii++) {
string column_name = reader.GetName (ii);
columns[ii] = column_name;
column_names[column_name] = ii;
column_names[column_name.ToUpper ()] = ii;
}
/* Read all rows, store in this->rows */
while (reader.Read ()) {
object[] data_row = new object[field_count];
for (ii = 0; ii < field_count; ii++) {
object value = reader.GetValue (ii);
if (Convert.IsDBNull (value))
value = null;
data_row[ii] = value;
}
rows.Add (data_row);
}
}
示例2: DataReturn
/// <summary>
/// 返回一個資料串
/// </summary>
public string DataReturn(SqliteDataReader data)
{
string database = "";
for (int i = 0; i < data.FieldCount; i++) {
// 資料是否為空
switch (data.IsDBNull(i)) {
case true:
switch (data.GetDataTypeName(i)){
case "TEXT":
database += "" + ",";
break;
case "INTEGER":
database += "" + 0 + ",";
break;
case "REAL":
database += "" + 0 + ",";
break;
default:
Debug.LogError("類型缺失");
return database;
}
break;
case false:
switch (data.GetDataTypeName(i)) {
case "TEXT":
database += data.GetString(i) + ",";
break;
case "INTEGER":
database += "" + data.GetInt32(i) + ",";
break;
case "REAL":
database += "" + data.GetFloat(i) + ",";
break;
default:
Debug.LogError("類型缺失");
return database;
}
break;
}
}
return database;
}