本文介绍了我怎样才能从sql中获取?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

label4.Text =;

if(!string.IsNullOrWhiteSpace(textBox1.Text))

{

if(! string.IsNullOrWhiteSpace(textBox2.Text))

{

SqlConnection connect = new SqlConnection(data source ='。'; initial catalog ='fastfood'; integrated security = true;);

connect.Open();

SqlCommand login = new SqlCommand(select admin(*)from admin where name_karbari ='+ textBox1.Text +'和ramze_obur ='+ textBox2.Text +',co​​nnect);

SqlDataReader r;

r = login.ExecuteReader();

int count = 0;

>>>>>>> >>>> while(r.read())

{

count ++;

}

if(count == 1 )//如果条件是真的吗?!登录否则访问被拒绝

{

label4.Text =لاگینشدید。;

}

else if (count == 0)

{

label4.Text =نامکاربرییاپسوردغلطاست。;

}

connect.Close();

}

else

{

label4.Text = رمزعبورنمیتواندخالیباشد。;

}

}

else

{

label4.Text =نامکاربرینمیتواندخالیباشد。;

}

当我运行此代码时,我显示的行有读取问题( );

我该怎么办?

label4.Text = "";
if (!string.IsNullOrWhiteSpace(textBox1.Text))
{
if (!string.IsNullOrWhiteSpace(textBox2.Text))
{
SqlConnection connect = new SqlConnection("data source =' . ';initial catalog='fastfood';integrated security=true;");
connect.Open();
SqlCommand login=new SqlCommand ("Select count (*) from admin where name_karbari='" + textBox1.Text + "' and ramze_obur='" + textBox2.Text + "', connect");
SqlDataReader r;
r = login.ExecuteReader();
int count = 0;
>>>>>>>>>>> while (r.read())
{
count++;
}
if (count == 1)//if is condition is true?! login else access denied
{
label4.Text = "لاگین شدید .";
}
else if(count==0)
{
label4.Text = "نام کاربری یا پسورد غلط است.";
}
connect.Close();
}
else
{
label4.Text = "رمز عبور نمی تواند خالی باشد .";
}
}
else
{
label4.Text = "نام کاربری نمی تواند خالی باشد .";
}
when i run this code، the line which i show has problem with read();
what should i do?

推荐答案


这篇关于我怎样才能从sql中获取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 03:48
查看更多