开发者

How update DB table with DataSet

I am begginer with ADO.NET , I try update table with DataSet. O client side I have dataset with one table. I send this dataset on service side (it is ASP.NET Web Service). On Service side I try update table in database, but it dont 't work.

public bool Update(DataSet ds) {

    SqlConnection conn = null;
    SqlD开发者_如何学GoataAdapter 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();
    }
}

Where can be problem?


It is better to look how really ADO.Net dataset works. http://support.microsoft.com/kb/308507

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜