检索unqiye标识符 [英] retrieve unqiye identifier
问题描述
我继续检索我的唯一标识符00000000-0000-0000-0000-000000000000。
如何从我的数据库中检索我的unqiue标识符。
这是正确的吗?
Guid code = Guid.Empty;我有一个从我的数据库中检索我的代码的方法
DAL
I keep retrieve my unique identifier as 00000000-0000-0000-0000-000000000000 .
How do I retrieve my unqiue identifier from my db.
Is this correct?
Guid code = Guid.Empty; I have a method to retrieve my code from my db
DAL
public bool getPin(Guid pin)
{
bool found = false;
string queryStr = "SELECT Pin FROM [Account] WHERE Name = @name";
SqlConnection conn = new SqlConnection(_connStr);
SqlCommand cmd = new SqlCommand(queryStr, conn);
cmd.Parameters.AddWithValue("@name", _name);
conn.Open();
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
pin = (Guid)dr["ActivationCode"];
name = dr["Name"].ToString();
found = true;
}
conn.Close();
dr.Close();
dr.Dispose();
return found;
}
BLL
BLL
public Guid FindPin(Guid pin)
{
string returnMessage = "";
if (pin == null)
{
Account account = new Account();
bool found = account.getPin(pin);
if (found == true)
{
returnMessage += "Your pin is wrong! <br />";
}
}
return pin;
}
演示层
Presentation Layer
AccountBLL ac = new AccountBLL();
Guid pin = Guid.Empty;
Guid pin1 = ac.FindPen(pin)
在...中添加了问题从以前版本的帖子[/ Edit]
Added the question back in from previous version of post[/Edit]
推荐答案
看看行
Guid pin = Guid.Empty;
Guid pin1 = ac.FindPen(pin)
首先你有一个拼写错误,但重要的是你传递 Guid.Empty
进入你的FindPin方法。
在这种方法中你只能尝试查找
Firstly you have a spelling error in there, but importantly you are passing Guid.Empty
into your FindPin method.
Within that method you only try to look something up
if (pin == null)
嗯,它不是null,它是Guid.Empty!
尝试
Well it's not null, it's Guid.Empty!
Try
if (pin == Guid.Empty)
这篇关于检索unqiye标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!