开发者

How update DB table with DataSet

开发者 https://www.devze.com 2022-12-24 01:52 出处:网络
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).

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

精彩评论

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