?
Solved

Adding a New Row using a DataView

Posted on 2003-02-21
3
Medium Priority
?
1,689 Views
Last Modified: 2008-09-12
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
Comment
Question by:kkondapalli
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 28

Accepted Solution

by:
iboutchkine earned 200 total points
ID: 7993970
*** 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
 

Expert Comment

by:rameshsraj
ID: 9120278
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9645327
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question