本文整理汇总了C#中System.Data.SqlClient.SqlCommand.GetInt64方法的典型用法代码示例。如果您正苦于以下问题:C# SqlCommand.GetInt64方法的具体用法?C# SqlCommand.GetInt64怎么用?C# SqlCommand.GetInt64使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SqlClient.SqlCommand
的用法示例。
在下文中一共展示了SqlCommand.GetInt64方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetUser
public long GetUser(string email, string hash)
{
long _result = -1;
if (Connected)
{
using (SqlDataReader _reader = new SqlCommand(string.Format("Select * from MarketUser Where Email='{0}'", email), _sql).ExecuteReader())
{
if (_reader.HasRows)
{
while (_reader.Read())
{
if (_reader.GetString(_reader.GetOrdinal("Password")).Equals(hash))
{
_result = _reader.GetInt64(_reader.GetOrdinal("UserId"));
}
}
}
}
}
return _result;
}
示例2: readFromDataBase
public void readFromDataBase()
{
items.Clear();
SqlDataReader reader = new SqlCommand(string.Format("SELECT * FROM Items ORDER BY Id;SELECT * FROM Jobs ORDER BY Item;SELECT * FROM Jobs ORDER BY Item;"), cn).ExecuteReader();
//читаем лист items
while (reader.Read())
{
item newItem = new item();
newItem.id = reader.GetInt32(0);
newItem.firstName = reader.GetString(1);
newItem.lastName = reader.GetString(2);
items.Add(newItem);
}
int i;
int lastid;
//читаем лист jobs
reader.NextResult();
lastid = i = -1;
while (reader.Read())
{
int k = reader.GetInt32(4);
if (lastid != k)
{
do ++i;
while (k != items[i].id);
lastid = reader.GetInt32(4);
}
items[i].jobs.Add(new job(reader.GetDateTime(0), reader.GetString(1), reader.GetString(2), reader.GetString(3)));
}
//читаем лист positions
reader.NextResult();
lastid = i = -1;
while (reader.Read())
{
if (lastid != reader.GetInt32(4))
{
do i++;
while (reader.GetInt32(4) != items[i].id);
lastid = reader.GetInt32(4);
}
items[i].positions.Add(new position(reader.GetInt64(0),reader.GetInt64(1),reader.GetInt32(2),reader.GetDateTime(3)));
}
reader.Close();
}