Some help with c# commandbuilder plsss....

Discussion in 'C#' started by cks, Jul 2, 2010.

  1. #1
    I'm fairly new to asp.net so please be patient..:)

    I've seen many examples online but I seem to have some trouble with this. I'm trying to create a db record with button1 with the current time, and update that record with button2 with the new current time.

    I got up to..
    SqlCommandBuilder builder = new SqlCommandBuilder(adapter);

    then I put..
    adapter.InsertCommand = builder.GetInsertCommand();

    into the button1 click event..

    what am I missing here?
     
    cks, Jul 2, 2010 IP
  2. bitstream

    bitstream Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    button1 click event

    SQLHelper.ExecuteNonQuery("insert into tablename(field1,...) values(value1, ...)");

    button2 click event

    SQLHelper.ExecuteNonQuery("update tablename set field1=value1, ... where id=" + id);
     
    bitstream, Jul 4, 2010 IP
  3. xtrecoolx

    xtrecoolx Greenhorn

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #3
    Ok but what is your insertcommand like? For instance if you want to read,
    SqlDataAdapter adapter = new SqlDataAdapter();
    adapter.SelectCommand = new SqlCommand(queryString, connection); <==
    SqlCommandBuilder builder = new SqlCommandBuilder(adapter);



     
    xtrecoolx, Jul 16, 2010 IP