2010-03-26 71 views
0

我是使用ADO.NET建立的,我嘗試使用DataSet更新表。 O客戶端我有一個表的數據集。我在服務端發送這個數據集(這是ASP.NET Web服務)。 在服務端我嘗試更新數據庫表,但它不工作。如何使用DataSet更新數據庫表

公共BOOL更新(DataSet的DS) {

SqlConnection conn = null; 
    SqlDataAdapter da = null; 
    SqlCommand cmd = null; 
    try 
    { 

     string sql = "UPDATE * FROM Tab1"; 

     string connStr = WebConfigurationManager.ConnectionStrings["Employees"].ConnectionString; 

     conn = new SqlConnection(connStr); 
     conn.Open(); 

     cmd=new SqlCommand(sql,conn); 

     da = new SqlDataAdapter(sql, conn); 
     da.UpdateCommand = cmd; 

     da.Update(ds.Tables[0]); 
     return true; 

    } 
    catch (Exception ex) 
    { 
     throw ex; 
    } 
    finally 
    { 
     if (conn != null) 
      conn.Close(); 
     if (da != null) 
      da.Dispose(); 
    } 
} 

在哪裏可以是問題嗎?

回答

相關問題