using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using MySql.Data.MySqlClient;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string ss = "select * from user";
String strContent = "Server=localhost;User ID=root;Password=root;Database=aspbigword;";
MySqlConnection con = new MySqlConnection(strContent);
MySqlCommand cmd = new MySqlCommand(ss, con);
con.Open();
DataSet ds = new DataSet();
MySqlDataAdapter aa = new MySqlDataAdapter(cmd);
aa.Fill(ds);//查询结果集填充数据集
MySqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
Response.Write("<script language=JavaScript>alert('登录成功!');location='Default1.aspx'</script>");
}
else
{
Response.Write("<script language=javascript>alert('登录失败!');location='javascript:history.Go(-1)'</script>");
}
dr.Close();
con.Close();
}
}
运行到con.open()时就出错,是什么问题? 谢谢