自己编写的database类,在ado.net中调用
public class DataBase
{
SqlConnection objConnection = null;
public DataBase()
{
//string ConnectionStr = System.Configuration.ConfigurationSettings.AppSettings["ConnectionStr"].ToString();
//string ConnectionStr = "Data Source=OEM-20120427JSK;Initial Catalog=test;Integrated Security=True";
objConnection = new SqlConnection(ConnectionStr);
}
public void doExe(string sql)
{
objConnection.Open();
SqlCommand cmd = new SqlCommand(sql, objConnection);
cmd.ExecuteNonQuery();
}
public class DataBase
{
SqlConnection objConnection = null;
public DataBase()
{
//string ConnectionStr = System.Configuration.ConfigurationSettings.AppSettings["ConnectionStr"].ToString();
//string ConnectionStr = "Data Source=OEM-20120427JSK;Initial Catalog=test;Integrated Security=True";
objConnection = new SqlConnection(ConnectionStr);
}
public void doExe(string sql)
{
objConnection.Open();
SqlCommand cmd = new SqlCommand(sql, objConnection);
cmd.ExecuteNonQuery();
}
public DataTable doSelect(string sql)
{
objConnection.Open();
SqlDataAdapter userInfoDAP = new SqlDataAdapter(sql, objConnection);
DataTable dt = new DataTable();
userInfoDAP.Fill(dt);
return dt;
}
{
objConnection.Open();
SqlDataAdapter userInfoDAP = new SqlDataAdapter(sql, objConnection);
DataTable dt = new DataTable();
userInfoDAP.Fill(dt);
return dt;
}
public void close()
{
objConnection.Close();
}
}
{
objConnection.Close();
}
}