如何调用不同类的临时数据
我想把数据全部放到临时数据库类里面,别的类也可以使用这个类里面的临时数据库。系统提示我“可访问性不一致”,
//临时数据库
class TransitDepot
{
DataSet ds = new DataSet();
SqlDataAdapter da = null;
DBHelper dbh = new DBHelper();
public static string sqlSinger = "";
public static string sqlSong = "";
public void SingerDepot()
{
da = new SqlDataAdapter(sqlSinger,dbh.Connection);
da.Fill(ds, "SingerDepot");
}
public void SongDepot()
{
da = new SqlDataAdapter(sqlSong, dbh.Connection);
da.Fill(ds, "SongDepot");
}
}
//在别的类里面把数据放在临时数据库类里面
public partial class FrmMain : Form
{
DBHelper dbh = new DBHelper();
StringBuilder sql = null;
DataSet ds = new DataSet();
SqlDataAdapter da = null;
private void FrmMain_Load(object sender, EventArgs e)
{
AddTransitDepot();
}
//添加歌手数据和歌曲数据到临时仓库
public void AddTransitDepot()
{
//查询歌手信息到仓库
sql = new StringBuilder("Select");
sql.AppendLine(" *");
sql.AppendLine("From");
sql.AppendLine(" [Singer_info]");
TransitDepot.sqlSinger = sql.ToString();
//查询歌曲信息到仓库
sql = new StringBuilder("Select");
sql.AppendLine(" *");
sql.AppendLine("From");
sql.AppendLine(" [Song_info]");
TransitDepot.sqlSong = sql.ToString();
}
}
//在别的类调用
public partial class FrmOrderBySinger : Form
{
public FrmOrderBySinger()
{
InitializeComponent();
}
DataSet ds = new DataSet();
public static FrmMain fm = new FrmMain();
public static FrmOrderBySinger FB = new FrmOrderBySinger();
public static TransitDepot td = new TransitDepot();
public void Into()
{
MessageBox.Show(ds.Tables["SingerDepot"].Columns.ToString());
}
}