就10分了,希望能得到您的帮助!!!
public void GetDataSet(string DbName,string FromName)
{
SqlConnection conn = new SqlConnection( "user id=sa;password=123456;initial catalog=master;data source=192.168.18.124;Connect Timeout=10 ");
DataSet ds=new DataSet();
conn.Open();
string sql= "use "+DbName+ " select * from "+FromName;
SqlDataAdapter da = new SqlDataAdapter(sql, conn);
da.Fill(ds);
conn.Close();
UpDataSet(ds, sql);
}
public void UpDataSet(DataSet Data,string sqlstr)
{
SqlConnection conn = new SqlConnection( "user id=sa;password=123456;initial catalog=master;data source=192.168.18.124;Connect Timeout=10 ");
DataSet ds = new DataSet();
conn.Open();
SqlDataAdapter da = new SqlDataAdapter(sqlstr, conn);
SqlCommandBuilder cb = new SqlCommandBuilder(da);
da.Fill(ds);
ds.Clear();
ds = Data.Copy();
da.Update(ds); //为什么我更新了没效果啊
}
我从一个数据源取数据得到DATASET 然后想更新到另一个数据源中
------解决方案--------------------我给我发一段代码吧:
try
{
string sconn2 = ConfigurationSettings.AppSettings[ "data "];
string sSqlupdate = "update XiaoShouBiao set yiyuan= ' " + y1 + " ',eryuan= ' " + y2 + " ',wuyuan= ' " + y5 + " ',shiyuan= ' " + y10 + " ',ershiyuan= ' " + y20 + " ',wushiyuan= ' " + y50 + " ', yiba