Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1701
  • Last Modified:

Adding a New Row using a DataView

I have a Datagrid Control that is bound to a Dataview and now I want to add New rows to that Datagrid that update the base Datatable of the DataView.

How Can I do this?

Thanks,
Kalyan.
0
kkondapalli
Asked:
kkondapalli
1 Solution
 
iboutchkineCommented:
*** SQL Statement
strSQL = "select * from Answer where ID = " & getLngID()

'*** Set up Adapter, DataSet
Dim daAns As New SqlDataAdapter(strSQL, mySQLConnection)
Dim dsAns As New DataSet("Answer")
daAns.FillSchema(dsAns, SchemaType.Source, "Answer")
daAns.Fill(dsAns, "Answer")

'*** Get the new row to edit
Dim drAns As DataRow
drAns = dsAns.Tables("Answer").NewRow()

'*** Enter data
drAns.BeginEdit()
drAns("Data") = getStrData()
drAns("trackingCode") = getStrTrackingCode()
drAns("CreationDateTime") = getDteCreationDateTime()
drAns.EndEdit()

'*** Add the row
dsAns.Tables("Answer").Rows.Add(drAns)

'*** Create Dataset Command
Dim cmdAns As New SqlCommandBuilder(daAns)
daAns.Update(dsAns, "Answer")

0
 
rameshsrajCommented:
hi
                   dtTblsize.DefaultView.AllowNew = True
                    dtTblsize.DefaultView.AddNew()
                    dtTblsize.DefaultView(index).Item(columnindex) = <value>
                    ....
                    ....
                    dtTblsize.DefaultView.AllowNew = False

hope this is enough from u
instead of using a  dataview u can directly use the defaultview method
of datatable.

bye

0
 
Bob LearnedCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered by iboutchkine

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

TheLearnedOne
EE Cleanup Volunteer
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now