日期:2014-05-16 浏览次数:20446 次
public MySqlConnection GetCon()
{
return new MySqlConnection(ConfigurationManager.AppSettings["MySqlStr"].ToString());
}
public int sqlEx(string cmdstr)
{
MySqlConnection con = GetCon();
con.Open();
MySqlCommand cmd = new MySqlCommand(cmdstr, con);
try
{
cmd.ExecuteNonQuery();
return 1;
}
catch (Exception)
{
return 0;
}
finally
{
con.Dispose();
}
}
public DataTable reDt(string cmdstr)
{
MySqlConnection con = GetCon();
MySqlDataAdapter da = new MySqlDataAdapter(cmdstr, con);
DataSet ds = new DataSet();
da.Fill(ds);
return (ds.Tables[0]);
}
public MySqlDataReader reDr(string str)
{
MySqlConnection conn = GetCon();
conn.Open();
MySqlCommand com = new MySqlCommand(str, conn);
MySqlDataReader dr = com.ExecuteReader(CommandBehavior.CloseConnection);
return dr;
&nb