大家来帮忙看一下这段代码!
Form1(void){
InitializeComponent();
UserName->SelectCommand->Parameters->Item[0]->Value=TBoxUserID->Text;
UserName->Fill(DataSetLogin,S"UserName");
if(this->DataSetLogin->Tables->Item[S"UserName"]->Rows->Count==0)
return;
this->TBoxUserName->Text=this->DataSetLogin->Tables->Item[S"UserName"]->Rows->Item[0]->Item[S"XingMing"]->ToString();
}
private: System::Void btnLogin_Click(System::Object * sender, System::EventArgs * e)
{
AdaptorLogin->SelectCommand->Parameters->Item[0]->Value=TBoxUserID->Text;
AdaptorLogin->SelectCommand->Parameters->Item[1]->Value=TBoxUserName->Text;
AdaptorLogin->SelectCommand->Parameters->Item[2]->Value=TBoxPassword->Text;
AdaptorLogin->Fill(DataSetLogin,S"Users");
if(DataSetLogin->Tables->Item[0]->Rows->Count>0)
{
MessageBox::Show(this,String::Concat(S"Welcome",TBoxUserName->Text),"In System");
strUserID=TBoxUserID->Text;
strUser=TBoxUserName->Text;
strDepartment=DataSetLogin->Tables->Item[0]->Columns->Item[1]->ToString();
this->DialogResult=DialogResult::OK;
}
else
{
MessageBox::Show(this,"UserName is Wrong! ","In System");
}
}
数据库里面有输入的用户名ID号,和密码但是老是说里面没有。
大家看看有什么问题么,谢谢各位了。 --------------------编程问答-------------------- 有点乱.代码. --------------------编程问答-------------------- Form1(void)
{
InitializeComponent();
UserName->SelectCommand->Parameters->Item[0]->Value=TBoxUserID->Text;
UserName->Fill(DataSetLogin,S"UserName");
if(this->DataSetLogin->Tables->Item[S"UserName"]->Rows->Count==0)
return;
this->TBoxUserName->Text=this->DataSetLogin->Tables->Item[S"UserName"]->Rows->Item[0]->Item[S"XingMing"]->ToString();
}
private: System::Void btnLogin_Click(System::Object * sender, System::EventArgs * e)
{
AdaptorLogin->SelectCommand->Parameters->Item[0]->Value=TBoxUserID->Text;
AdaptorLogin->SelectCommand->Parameters->Item[1]->Value=TBoxUserName->Text;
AdaptorLogin->SelectCommand->Parameters->Item[2]->Value=TBoxPassword->Text;
AdaptorLogin->Fill(DataSetLogin,S"Users");
if(DataSetLogin->Tables->Item[0]->Rows->Count>0)
{
MessageBox::Show(this,String::Concat(S"Welcome",TBoxUserName->Text),"In System");
strUserID=TBoxUserID->Text;
strUser=TBoxUserName->Text;
strDepartment=DataSetLogin->Tables->Item[0]->Columns->Item[1]->ToString();
this->DialogResult=DialogResult::OK;
}
else
{
MessageBox::Show(this,"UserName is Wrong! ","In System");
}
}
--------------------编程问答-------------------- 这样还有问题么? --------------------编程问答-------------------- 代码有点乱,问题也有点不明确
应该是说AdaptorLogin->Fill(DataSetLogin,S"Users");这个地方,fill之后,DataSet还是没有数据吧,又不知道你selectcommand是怎么设置的,没你这个查法。你最好再调试调试,把问题范围缩小一点
另外,我觉得有点奇怪,为什么要一直去fill?有没有必要用DataSet
如果只是做登录验证,写个存储过程或者sql去查查看是不是exist不就行了? --------------------编程问答-------------------- 我想请教以下DataSet的selectcommand是如何设置呢,我怎么找这个的设置项都找不到呢。我也是刚学c++.net请指教。
补充:.NET技术 , VC.NET