help !

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.]
 
D

Dhaval Naik

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))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,150
Latest member
MakersCBDReviews
Top