help !

  • Thread starter Thread starter dotnethelp
  • Start date Start date
D

dotnethelp

Suppose I have 2 textboxes txtRollno and txtName to input data from user

.. When I press a button (btnInsert) to insert a row from user then it

inserts a new row and puts data of textboxes in that row .

There is another button (btnSave) to save the record permanently in actual

table. My code is



Event is :

BtnInsert_Click

Code is :

DataRow dr=DataSet1.Tables(0).newrow

dr(0)=txtRollno.Text

dr(1)=txtName.Text

DataSet1.Tables(0).Rows.Add(dr)

[ When I test it then new row is reflected to DataSet1]





Event is :

BtnSave_Click

Code is :

Dim cmp as new sqlCommandBuilder(sqlDataAdapter1)

SqlDataAdapter1.Update(DataSet1.Tables(0))

[ At this stage it is not updating new rows in actual table. Even it is

displaying old

data in dataset not updated data which was displaying in previous button

click. How can I solve this problem.]
 
You need to call your BtnInsert_Click event before you actually save your
data in your BtnSave_Click event. Something like this.

BtnSave_Click

Code is :

Call BtnInsert_Click()

Dim cmp as new sqlCommandBuilder(sqlDataAdapter1)

SqlDataAdapter1.Update(DataSet1.Tables(0))
 
Back
Top