SqlCommandBuilder

Discussion in 'ASP .Net' started by =?Utf-8?B?SmltIFJleW5vbGRz?=, May 12, 2005.

  1. Hi,
    I am using a SqlCommandBuilder to update a Db table via an updated DataSet
    and SqlAdapter and it doesn't seem to be generating the activity commands
    from the Select command. Here is a snippet.

    sda = new SqlDataAdapter();
    sda.SelectCommand = new SqlCommand(sql,dbcon);
    SqlCommandBuilder scb = new SqlCommandBuilder(sda);

    DataSet ds = new DataSet();
    sda.Fill(ds,pageName);

    DataRow dr = ds.Tables[pageName].NewRow();

    for(int x=0;x<14;x++)
    {
    dr[x] = newDataRow[x];
    }
    ds.Tables[pageName].Rows.Add(dr);
    ds.AcceptChanges();
    sda.Update(ds,pageName);

    Nothing happens, no update and no exceptions. Any ideas please?

    Jim
     
    =?Utf-8?B?SmltIFJleW5vbGRz?=, May 12, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?SmltIFJleW5vbGRz?=

    Marina Guest

    Yes - you called AcceptChanges. This changes the states of all the rows to
    unmodified. So when you go to update, it looks like there is nothing to
    update.

    Why call AcceptChanges to change all the row states if you then want to
    update?

    "Jim Reynolds" <> wrote in message
    news:...
    > Hi,
    > I am using a SqlCommandBuilder to update a Db table via an updated DataSet
    > and SqlAdapter and it doesn't seem to be generating the activity commands
    > from the Select command. Here is a snippet.
    >
    > sda = new SqlDataAdapter();
    > sda.SelectCommand = new SqlCommand(sql,dbcon);
    > SqlCommandBuilder scb = new SqlCommandBuilder(sda);
    >
    > DataSet ds = new DataSet();
    > sda.Fill(ds,pageName);
    >
    > DataRow dr = ds.Tables[pageName].NewRow();
    >
    > for(int x=0;x<14;x++)
    > {
    > dr[x] = newDataRow[x];
    > }
    > ds.Tables[pageName].Rows.Add(dr);
    > ds.AcceptChanges();
    > sda.Update(ds,pageName);
    >
    > Nothing happens, no update and no exceptions. Any ideas please?
    >
    > Jim
     
    Marina, May 12, 2005
    #2
    1. Advertising

  3. Doh!

    Thanks very much Marina. Why would you need to call AcceptChanges on a
    DataSet?

    Jim

    "Marina" wrote:

    > Yes - you called AcceptChanges. This changes the states of all the rows to
    > unmodified. So when you go to update, it looks like there is nothing to
    > update.
    >
    > Why call AcceptChanges to change all the row states if you then want to
    > update?
    >
    > "Jim Reynolds" <> wrote in message
    > news:...
    > > Hi,
    > > I am using a SqlCommandBuilder to update a Db table via an updated DataSet
    > > and SqlAdapter and it doesn't seem to be generating the activity commands
    > > from the Select command. Here is a snippet.
    > >
    > > sda = new SqlDataAdapter();
    > > sda.SelectCommand = new SqlCommand(sql,dbcon);
    > > SqlCommandBuilder scb = new SqlCommandBuilder(sda);
    > >
    > > DataSet ds = new DataSet();
    > > sda.Fill(ds,pageName);
    > >
    > > DataRow dr = ds.Tables[pageName].NewRow();
    > >
    > > for(int x=0;x<14;x++)
    > > {
    > > dr[x] = newDataRow[x];
    > > }
    > > ds.Tables[pageName].Rows.Add(dr);
    > > ds.AcceptChanges();
    > > sda.Update(ds,pageName);
    > >
    > > Nothing happens, no update and no exceptions. Any ideas please?
    > >
    > > Jim

    >
    >
    >
     
    =?Utf-8?B?SmltIFJleW5vbGRz?=, May 13, 2005
    #3
  4. =?Utf-8?B?SmltIFJleW5vbGRz?=

    Marina Guest

    If you used GetChanges to get just the changes, and after the save was done,
    you wanted to reset all the rows to unchanged, to match.

    Or if you had application logic the required you for some reason to want
    this to happen.

    "Jim Reynolds" <> wrote in message
    news:...
    > Doh!
    >
    > Thanks very much Marina. Why would you need to call AcceptChanges on a
    > DataSet?
    >
    > Jim
    >
    > "Marina" wrote:
    >
    >> Yes - you called AcceptChanges. This changes the states of all the rows
    >> to
    >> unmodified. So when you go to update, it looks like there is nothing to
    >> update.
    >>
    >> Why call AcceptChanges to change all the row states if you then want to
    >> update?
    >>
    >> "Jim Reynolds" <> wrote in message
    >> news:...
    >> > Hi,
    >> > I am using a SqlCommandBuilder to update a Db table via an updated
    >> > DataSet
    >> > and SqlAdapter and it doesn't seem to be generating the activity
    >> > commands
    >> > from the Select command. Here is a snippet.
    >> >
    >> > sda = new SqlDataAdapter();
    >> > sda.SelectCommand = new SqlCommand(sql,dbcon);
    >> > SqlCommandBuilder scb = new SqlCommandBuilder(sda);
    >> >
    >> > DataSet ds = new DataSet();
    >> > sda.Fill(ds,pageName);
    >> >
    >> > DataRow dr = ds.Tables[pageName].NewRow();
    >> >
    >> > for(int x=0;x<14;x++)
    >> > {
    >> > dr[x] = newDataRow[x];
    >> > }
    >> > ds.Tables[pageName].Rows.Add(dr);
    >> > ds.AcceptChanges();
    >> > sda.Update(ds,pageName);
    >> >
    >> > Nothing happens, no update and no exceptions. Any ideas please?
    >> >
    >> > Jim

    >>
    >>
    >>
     
    Marina, May 13, 2005
    #4
  5. Thanks very much.

    "Marina" wrote:

    > If you used GetChanges to get just the changes, and after the save was done,
    > you wanted to reset all the rows to unchanged, to match.
    >
    > Or if you had application logic the required you for some reason to want
    > this to happen.
    >
    > "Jim Reynolds" <> wrote in message
    > news:...
    > > Doh!
    > >
    > > Thanks very much Marina. Why would you need to call AcceptChanges on a
    > > DataSet?
    > >
    > > Jim
    > >
    > > "Marina" wrote:
    > >
    > >> Yes - you called AcceptChanges. This changes the states of all the rows
    > >> to
    > >> unmodified. So when you go to update, it looks like there is nothing to
    > >> update.
    > >>
    > >> Why call AcceptChanges to change all the row states if you then want to
    > >> update?
    > >>
    > >> "Jim Reynolds" <> wrote in message
    > >> news:...
    > >> > Hi,
    > >> > I am using a SqlCommandBuilder to update a Db table via an updated
    > >> > DataSet
    > >> > and SqlAdapter and it doesn't seem to be generating the activity
    > >> > commands
    > >> > from the Select command. Here is a snippet.
    > >> >
    > >> > sda = new SqlDataAdapter();
    > >> > sda.SelectCommand = new SqlCommand(sql,dbcon);
    > >> > SqlCommandBuilder scb = new SqlCommandBuilder(sda);
    > >> >
    > >> > DataSet ds = new DataSet();
    > >> > sda.Fill(ds,pageName);
    > >> >
    > >> > DataRow dr = ds.Tables[pageName].NewRow();
    > >> >
    > >> > for(int x=0;x<14;x++)
    > >> > {
    > >> > dr[x] = newDataRow[x];
    > >> > }
    > >> > ds.Tables[pageName].Rows.Add(dr);
    > >> > ds.AcceptChanges();
    > >> > sda.Update(ds,pageName);
    > >> >
    > >> > Nothing happens, no update and no exceptions. Any ideas please?
    > >> >
    > >> > Jim
    > >>
    > >>
    > >>

    >
    >
    >
     
    =?Utf-8?B?SmltIFJleW5vbGRz?=, May 16, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rico Alexander
    Replies:
    1
    Views:
    373
    zPaul
    Oct 23, 2003
  2. microsoft.private.windows.netserver.setup

    Stored Procedures with SQLCommandBuilder

    microsoft.private.windows.netserver.setup, Mar 6, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    2,882
    microsoft.private.windows.netserver.setup
    Mar 6, 2004
  3. microsoft.private.windows.netserver.setup

    Datagrid and SqlCommandBuilder

    microsoft.private.windows.netserver.setup, Mar 6, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    133
    microsoft.private.windows.netserver.setup
    Mar 6, 2004
  4. microsoft.private.windows.netserver.setup

    Stored Procedures with SQLCommandBuilder

    microsoft.private.windows.netserver.setup, Mar 6, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    149
    microsoft.private.windows.netserver.setup
    Mar 6, 2004
Loading...

Share This Page