PS:我查了下,网上很多说用driver,不过不支持
public partial class kaipiaoziliao_loginpage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = " Server=i-server;database=fapiao;integrated security=SSPI;";
SqlCommand objcmd = new SqlCommand();
objcmd.Connection = con;
objcmd.CommandText = "select shuihao from cheeck where shuihao='" + Convert.ToInt32(TextBox1.Text.Trim()) + "'";
con.Open();
SqlDataReader dr = objcmd.ExecuteReader();
if (dr.Read())
{
Session["shuihao"] = TextBox1.Text.Trim();
Response.Redirect("cheeck.aspx");
}
else
{ Response.Write("<script language='javascript'>window.alert('您的输入有误,请重新输入!');</script>"); }
}
}
上面的是我的程序段,不过运行时都出现 SqlDataReader dr = objcmd.ExecuteReader();这一行的错误,是不是因为数据库没连上的缘故??求教~~在线等