Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. wating for anser how to add record to database with gridjanus and bindingnavigator

wating for anser how to add record to database with gridjanus and bindingnavigator

Scheduled Pinned Locked Moved C#
databasecsswpfwcfhelp
6 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fatemehsoleimani
    wrote on last edited by
    #1

    hi every one i want add a one record to sql from grid janus and one cell from a editbox control with binding navigator but can not add and message show column code can not null. my source code:

    private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
    {
    codemax = Convert.ToInt32(fatemeTableAdapter.maxcode());
    codemax = codemax + 1;

           editBox1.Text = codemax.ToString();
           ((DataRowView)fatemeBindingSource1.Current).Row\["code"\] = codemax;
       }
    

    and savebinding:

    private void save_Click(object sender, EventArgs e)
    {
    int g, b;
    g=Convert.ToInt32(gridEX1.CurrentRow.Cells["code_b"].Value);
    b=Convert.ToInt32(gridEX1.CurrentRow.Cells["name"].Value) ;
    ((DataRowView)fatemeBindingSource1.Current).Row["code_b"] = g;
    ((DataRowView)fatemeBindingSource1.Current).Row["name"] = b;

            this.Validate();
            fatemeBindingSource1.EndEdit();
            fatemeTableAdapter.Update(this.baziDataSet1.fateme);
        }
    

    i dont how get value from new row in grid please help me best a regards

    F 2 Replies Last reply
    0
    • F fatemehsoleimani

      hi every one i want add a one record to sql from grid janus and one cell from a editbox control with binding navigator but can not add and message show column code can not null. my source code:

      private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
      {
      codemax = Convert.ToInt32(fatemeTableAdapter.maxcode());
      codemax = codemax + 1;

             editBox1.Text = codemax.ToString();
             ((DataRowView)fatemeBindingSource1.Current).Row\["code"\] = codemax;
         }
      

      and savebinding:

      private void save_Click(object sender, EventArgs e)
      {
      int g, b;
      g=Convert.ToInt32(gridEX1.CurrentRow.Cells["code_b"].Value);
      b=Convert.ToInt32(gridEX1.CurrentRow.Cells["name"].Value) ;
      ((DataRowView)fatemeBindingSource1.Current).Row["code_b"] = g;
      ((DataRowView)fatemeBindingSource1.Current).Row["name"] = b;

              this.Validate();
              fatemeBindingSource1.EndEdit();
              fatemeTableAdapter.Update(this.baziDataSet1.fateme);
          }
      

      i dont how get value from new row in grid please help me best a regards

      F Offline
      F Offline
      fatemehsoleimani
      wrote on last edited by
      #2

      i am tierd please help me.i am trying for find reply question a long time.i am tierd. i am set allowaddnew equal true.it might read from new record in grid that is bound and editbox that is unbound and add to data base and add to grid that show error column code can not be null that column code is editbox control and i was delete from column grid. or i should all coulmn from table in out gird and read from there and add to grid and database .i am mixed up :(( best a regards

      F 1 Reply Last reply
      0
      • F fatemehsoleimani

        i am tierd please help me.i am trying for find reply question a long time.i am tierd. i am set allowaddnew equal true.it might read from new record in grid that is bound and editbox that is unbound and add to data base and add to grid that show error column code can not be null that column code is editbox control and i was delete from column grid. or i should all coulmn from table in out gird and read from there and add to grid and database .i am mixed up :(( best a regards

        F Offline
        F Offline
        fatemehsoleimani
        wrote on last edited by
        #3

        that program in first time add a record to database and grid but in secend time show message error column code can not be null. and one problem in select a new row in grid when a type a value for a column that column is to be select and anather column not to be select and then in add record to sql one of column is 0 value. that how total record in select case. please help me :doh: :confused: :( best a regards

        F 1 Reply Last reply
        0
        • F fatemehsoleimani

          that program in first time add a record to database and grid but in secend time show message error column code can not be null. and one problem in select a new row in grid when a type a value for a column that column is to be select and anather column not to be select and then in add record to sql one of column is 0 value. that how total record in select case. please help me :doh: :confused: :( best a regards

          F Offline
          F Offline
          fatemehsoleimani
          wrote on last edited by
          #4

          my god i am tierd please help me. :confused:

          F 1 Reply Last reply
          0
          • F fatemehsoleimani

            my god i am tierd please help me. :confused:

            F Offline
            F Offline
            fatemehsoleimani
            wrote on last edited by
            #5

            i dont english as well .from all friend want to guide me for solve my problem. i am very very hope that this site firend my problem resolved... best regards

            1 Reply Last reply
            0
            • F fatemehsoleimani

              hi every one i want add a one record to sql from grid janus and one cell from a editbox control with binding navigator but can not add and message show column code can not null. my source code:

              private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
              {
              codemax = Convert.ToInt32(fatemeTableAdapter.maxcode());
              codemax = codemax + 1;

                     editBox1.Text = codemax.ToString();
                     ((DataRowView)fatemeBindingSource1.Current).Row\["code"\] = codemax;
                 }
              

              and savebinding:

              private void save_Click(object sender, EventArgs e)
              {
              int g, b;
              g=Convert.ToInt32(gridEX1.CurrentRow.Cells["code_b"].Value);
              b=Convert.ToInt32(gridEX1.CurrentRow.Cells["name"].Value) ;
              ((DataRowView)fatemeBindingSource1.Current).Row["code_b"] = g;
              ((DataRowView)fatemeBindingSource1.Current).Row["name"] = b;

                      this.Validate();
                      fatemeBindingSource1.EndEdit();
                      fatemeTableAdapter.Update(this.baziDataSet1.fateme);
                  }
              

              i dont how get value from new row in grid please help me best a regards

              F Offline
              F Offline
              fatemehsoleimani
              wrote on last edited by
              #6

              i have one table with 3 column=code,name,code_b and in form i have a bindingnavigator that addnewitem=none and bindingsource=fatemebinding and in gridex datasourc=fatemebinding and in gridex allownew=addnew and rowheader=true and headercontent =rowposition and in griddesignert click in createroottable and retrive table and then column table ceated and then code envirement newiconbinding: [php] try { fatemeBindingSource.AddNew(); codmax = Convert.ToInt32(fatemeTableAdapter.maxcode()); codmax = codmax + 1; gridEX1.CurrentRow.Cells["code"].Value = codmax; ((DataRowView)fatemeBindingSource.Current).Row["code"] = codmax; } catch { MessageBox.Show("لطفا اطلاعات را وارد کنید"); } [/php] and save iconbindingnavator: [php] private void toolStripButton1_Click(object sender, EventArgs e) { fatemeBindingSource.EndEdit(); fatemeTableAdapter.Update(this.baziDataSet1.fateme); } [/php] but in run name and code_b value to be null how to asign data column please help me

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups