数据库连接
和数据库连接的时候能直接用设置链接码? 我用程序编的老调试不通。154867075 这是我的QQ号码。如果有谁愿意帮我先谢谢了
private void linkSql()
{
SqlConnection conn;
DataSet ds = new DataSet();
SqlDataAdapter sda;
conn = new SqlConnection(ConfigurationSettings.AppSettings["constr"]);
sda = new SqlDataAdapter("SELECT username,userpwd FROM User WHERE CompanyID = '"+ cid +"'",conn);
try
{
sda.Fill(ds,"user");
conn.Open();
DataRow dr;
for(int i=0;i<ds.Tables["user"].Rows.Count;i++)
{
dr = ds.Tables["user"].Rows[i];
if(ds.Tables["user"].Rows[i].ItemArray.GetValue(0).ToString() != unm.ToString())
{
l4.Text = "用户名错误!";
tbunm.Text = "";
}
else if(ds.Tables["user"].Rows[i].ItemArray.GetValue(1).ToString() != pwd.ToString())
{
l4.Text = "密码错误!";
tbpwd.Text = "";
}
else
{
Session["cid"] = cid;
Response.Redirect("Form1.cs");
}
}
}
catch(Exception ex)
{
Response.Write(ex);
}
finally
{
conn.Close();
}
}
[此贴子已经被作者于2007-3-13 13:50:44编辑过]