please helpppp how to add record to database with gridjanus

Oct 6 2014 1:39 PM
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:
<pre lang="cs">private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
{
codemax = Convert.ToInt32(fatemeTableAdapter.maxcode());
codemax = codemax + 1;
editBox1.Text = codemax.ToString();
((DataRowView)fatemeBindingSource1.Current).Row[&quot;code&quot;] = codemax;
}</pre>
and savebinding:
<pre lang="cs">private void save_Click(object sender, EventArgs e)
{
int g, b;
g=Convert.ToInt32(gridEX1.CurrentRow.Cells[&quot;code_b&quot;].Value);
b=Convert.ToInt32(gridEX1.CurrentRow.Cells[&quot;name&quot;].Value) ;
((DataRowView)fatemeBindingSource1.Current).Row[&quot;code_b&quot;] = g;
((DataRowView)fatemeBindingSource1.Current).Row[&quot;name&quot;] = b;
this.Validate();
fatemeBindingSource1.EndEdit();
fatemeTableAdapter.Update(this.baziDataSet1.fateme);
}</pre>
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
best a regards