读取的方法
namespace ClassLibrary1
{
public class Class1
{
SqlConnection cn = new SqlConnection("server=.;database=xBlog;uid=sa;pwd=sa");
public bool GetUser(string name, string pwd)
{
SqlCommand cmd = new SqlCommand("select count(*) from Users where UserName='" + name + "' and UserPassword='" + pwd + "'", cn);
cn.Open();
int count = -1;
count = Convert.ToInt32(cmd.ExecuteScalar());
if (count > 0)
{
return true;
}
return false;
}
}
}
用来调用
ClassLibrary1.Class1 cla = new ClassLibrary1.Class1();
bool a=cla.GetUser(TextBox1.Text, TextBox2.Text);
if (a == true)
{
Response.Write("login");
}
else
{
Response.Write(false);
}
namespace ClassLibrary1
{
public class Class1
{
SqlConnection cn = new SqlConnection("server=.;database=xBlog;uid=sa;pwd=sa");
public bool GetUser(string name, string pwd)
{
SqlCommand cmd = new SqlCommand("select count(*) from Users where UserName='" + name + "' and UserPassword='" + pwd + "'", cn);
cn.Open();
int count = -1;
count = Convert.ToInt32(cmd.ExecuteScalar());
if (count > 0)
{
return true;
}
return false;
}
}
}
用来调用
ClassLibrary1.Class1 cla = new ClassLibrary1.Class1();
bool a=cla.GetUser(TextBox1.Text, TextBox2.Text);
if (a == true)
{
Response.Write("login");
}
else
{
Response.Write(false);
}