本文整理汇总了C#中SqlStatement.ExecuteScalar方法的典型用法代码示例。如果您正苦于以下问题:C# SqlStatement.ExecuteScalar方法的具体用法?C# SqlStatement.ExecuteScalar怎么用?C# SqlStatement.ExecuteScalar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SqlStatement
的用法示例。
在下文中一共展示了SqlStatement.ExecuteScalar方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteInsert
public override LastInsertId ExecuteInsert(SqlStatement sql, string idKey)
{
sql.Sql += ";SELECT LAST_INSERT_ID()";
using (sql)
{
var rez = sql.ExecuteScalar();
return new LastInsertId(rez);
}
}
示例2: ExecuteInsert
public override LastInsertId ExecuteInsert(SqlStatement sql, string idKey)
{
sql.Sql += ";Select SCOPE_IDENTITY() as id";
using (sql)
{
var rez = sql.ExecuteScalar();
return new LastInsertId(rez);
}
}
示例3: ExecuteInsert
public override LastInsertId ExecuteInsert(SqlStatement sql, string idKey)
{
if (!string.IsNullOrEmpty(idKey))
{
sql.Sql += (" returning "+EscapeName(idKey));
}
using(sql)
{
return new LastInsertId(sql.ExecuteScalar());
}
}
示例4: ExecuteInsert
public override LastInsertId ExecuteInsert(SqlStatement sql, string idKey)
{
if (idKey != null)
{
sql.Sql += ";SELECT last_insert_rowid()";
using (sql)
{
var rez = sql.ExecuteScalar();
return new LastInsertId(rez);
}
}
sql.Execute();
return LastInsertId.Empty;
}
示例5: ExecuteInsert
public override LastInsertId ExecuteInsert(SqlStatement sql, string idKey)
{
//sql.Sql += ";Select @@IDENTITY as id";
using (sql)
{
sql.Execute();
using (var idquery = new SqlStatement(sql.Db))
{
idquery.SetSql("select @@IDENTITY as id");
var rez = idquery.ExecuteScalar();
return new LastInsertId(rez);
}
}
}