本文整理汇总了C#中System.Data.SQLite.SQLiteCommand.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# SQLiteCommand.ToString方法的具体用法?C# SQLiteCommand.ToString怎么用?C# SQLiteCommand.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SQLite.SQLiteCommand
的用法示例。
在下文中一共展示了SQLiteCommand.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GMSELF
/// <summary>
/// Gets the logged in GM name from the database.
/// </summary>
/// <returns>String containing currently logged in GM name.</returns>
internal static string GMSELF()
{
using (SQLiteConnection db = OPENDB())
{
string queryString = "SELECT `Name` FROM `gm` WHERE `Name` = (SELECT `Data` FROM `Data` WHERE `Name` = 'Login' LIMIT 1) COLLATE NOCASE LIMIT 1";
object result = new SQLiteCommand(queryString, db).ExecuteScalar();
if (result == null)
return "";
else
return result.ToString();
}
}
示例2: GenerateUID
/// <summary>
/// Generates a uniquely incremented ID based off of the currently logged in GM's ID and the table in question.
/// </summary>
/// <param name="table">The table that will require the unique ID.</param>
/// <returns>A long integer containing a unique ID.</returns>
internal static long GenerateUID(string table)
{
var db = OPENDB();
string GM = GMSELF();
string queryString = "SELECT MAX(ID) FROM `" + table + "` WHERE GM = '" + GM + "' COLLATE NOCASE;";
object result = new SQLiteCommand(queryString, db).ExecuteScalar();
if(result != null && result.ToString() != "")
{
long maxID = Int64.Parse(result.ToString());
//Create a deca-shift
int GMID = IDFromGM(GM);
int digitCount = (int)Math.Log10((double)GMID);
digitCount++; //Now have the number of digits in the ID
//Divide by the number of digits in the GMID to get rid of it.
maxID /= (int)Math.Pow(10, digitCount);
//Now we're left with just the increment portion. Increment it.
maxID++;
//Reassemble unique ID. It's out new max ID.
maxID = long.Parse(maxID + "" + GMID);
return maxID;
}
else
{
return long.Parse("1" + IDFromGM(GM));
}
}
示例3: ExecuteScalar
/// <summary>
/// Retrieve single items from the DB.
/// </summary>
/// <param name="sql">The query to run.</param>
/// <returns>A string.</returns>
public string ExecuteScalar(string sql)
{
SQLiteConnection connection = new SQLiteConnection(connectionString);
try
{
connection.Open();
var value = new SQLiteCommand(connection)
{
CommandText = sql
}.ExecuteScalar();
if (value != null)
{
return (value.ToString());
}
return (string.Empty);
}
catch
{
return (string.Empty);
}
finally
{
connection.Close();
}
}