Modifying Existing Data

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MikeY

    #1

    Modifying Existing Data

    Hi everyone,

    Using C#, Windows forms. I am trying to learn how to modify existing data
    with in MSDE table/fields. If anyone could help me out with my code, I would
    appreciate it. My code is as follows:

    private void btnEmpModify_Cl ick(object sender, System.EventArg s e)
    {
    DataTable thisTable = dsModifyRecord. Tables["Employee"];
    //THIS IS WHERE I'M GETTING LOST
    DataRow thisRow = thisTable?????? ?????????

    thisRow["EmplNumber "] = txtBoxEmplNumbe r.Text;
    thisRow["EmpFName"] = txtBoxEmpFName. Text;
    thisRow["EmpLName"] = txtBoxLNName.Te xt;
    thisRow["DateModifi ed"] = DateTime.Now.To String();
    thisRow["EmployeeNo tes"] = txtBoxEmpNotes. Text;

    //& GETTING LOST HERE
    dsModifyRecord. Tables["EMPLOYEE"]??????????????
    sqlDataAdapter1 .Update(dsModif yRecord, "Employee") ;
    }

    Thank you all in advance.

    MikeY



  • Chris Capel

    #2
    Re: Modifying Existing Data

    thisRow = thisTable.Rows[indexOfRowToMod ify];

    Keep in mind that data shown in any databound control should be in the same
    order as in the table, so there's a direct mapping of row indices.

    Chris

    "MikeY" <mikesinfo@yaho o.ca> wrote in message
    news:eMWVaKsVDH A.2236@TK2MSFTN GP12.phx.gbl...[color=blue]
    > Hi everyone,
    >
    > Using C#, Windows forms. I am trying to learn how to modify existing data
    > with in MSDE table/fields. If anyone could help me out with my code, I[/color]
    would[color=blue]
    > appreciate it. My code is as follows:
    >
    > private void btnEmpModify_Cl ick(object sender, System.EventArg s e)
    > {
    > DataTable thisTable = dsModifyRecord. Tables["Employee"];
    > //THIS IS WHERE I'M GETTING LOST
    > DataRow thisRow = thisTable?????? ?????????
    >
    > thisRow["EmplNumber "] = txtBoxEmplNumbe r.Text;
    > thisRow["EmpFName"] = txtBoxEmpFName. Text;
    > thisRow["EmpLName"] = txtBoxLNName.Te xt;
    > thisRow["DateModifi ed"] = DateTime.Now.To String();
    > thisRow["EmployeeNo tes"] = txtBoxEmpNotes. Text;
    >
    > //& GETTING LOST HERE
    > dsModifyRecord. Tables["EMPLOYEE"]??????????????
    > sqlDataAdapter1 .Update(dsModif yRecord, "Employee") ;
    > }
    >
    > Thank you all in advance.
    >
    > MikeY
    >
    >
    >[/color]


    Comment

    • MikeY

      #3
      Re: Modifying Existing Data

      Hi Chris,

      Thank you for information.
      However this is still a little fuzzey. I will look for an example. Where it
      is being fuzzy is that if at run time, if I don't know what row I will be
      modifying, then how do I write the syntex for that particular row ahead of
      time.

      Txs again
      MikeY

      "Chris Capel" <chris@nowhere. com> wrote in message
      news:e2xh91sVDH A.2352@TK2MSFTN GP12.phx.gbl...[color=blue]
      > thisRow = thisTable.Rows[indexOfRowToMod ify];
      >
      > Keep in mind that data shown in any databound control should be in the[/color]
      same[color=blue]
      > order as in the table, so there's a direct mapping of row indices.
      >
      > Chris
      >
      > "MikeY" <mikesinfo@yaho o.ca> wrote in message
      > news:eMWVaKsVDH A.2236@TK2MSFTN GP12.phx.gbl...[color=green]
      > > Hi everyone,
      > >
      > > Using C#, Windows forms. I am trying to learn how to modify existing[/color][/color]
      data[color=blue][color=green]
      > > with in MSDE table/fields. If anyone could help me out with my code, I[/color]
      > would[color=green]
      > > appreciate it. My code is as follows:
      > >
      > > private void btnEmpModify_Cl ick(object sender, System.EventArg s e)
      > > {
      > > DataTable thisTable = dsModifyRecord. Tables["Employee"];
      > > //THIS IS WHERE I'M GETTING LOST
      > > DataRow thisRow = thisTable?????? ?????????
      > >
      > > thisRow["EmplNumber "] = txtBoxEmplNumbe r.Text;
      > > thisRow["EmpFName"] = txtBoxEmpFName. Text;
      > > thisRow["EmpLName"] = txtBoxLNName.Te xt;
      > > thisRow["DateModifi ed"] = DateTime.Now.To String();
      > > thisRow["EmployeeNo tes"] = txtBoxEmpNotes. Text;
      > >
      > > //& GETTING LOST HERE
      > > dsModifyRecord. Tables["EMPLOYEE"]??????????????
      > > sqlDataAdapter1 .Update(dsModif yRecord, "Employee") ;
      > > }
      > >
      > > Thank you all in advance.
      > >
      > > MikeY
      > >
      > >
      > >[/color]
      >
      >[/color]


      Comment

      Working...