Click here to Skip to main content
15,916,949 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Multiuser VB Project Pin
raaman8-Aug-07 17:19
raaman8-Aug-07 17:19 
GeneralRe: Multiuser VB Project Pin
Bino B10-Aug-07 5:02
Bino B10-Aug-07 5:02 
GeneralRe: Multiuser VB Project Pin
raaman10-Aug-07 17:24
raaman10-Aug-07 17:24 
Questionany image must always go in my.resources???? Pin
jamilkhan0077-Aug-07 20:15
jamilkhan0077-Aug-07 20:15 
AnswerRe: any image must always go in my.resources???? Pin
Luc Pattyn8-Aug-07 0:08
sitebuilderLuc Pattyn8-Aug-07 0:08 
Question"mybase.inputlanguagechanging" does not accur! Pin
jamilkhan0077-Aug-07 20:10
jamilkhan0077-Aug-07 20:10 
AnswerRe: "mybase.inputlanguagechanging" does not accur! Pin
Dave Kreskowiak8-Aug-07 3:39
mveDave Kreskowiak8-Aug-07 3:39 
QuestionUpdating a Database via Datagrid Problem Pin
Trupti Mehta7-Aug-07 19:37
Trupti Mehta7-Aug-07 19:37 
Hello,

In my small VB .NEt 2005 program. MS Access Database is coonnected via "Add New Souce" & added to the project. I have a DataGrid that is bound to a data source (Dataset) and Data Member is (tableName). I retreive data on basis of selection in the List. A query is called & saved based on List Selected item. Datasource of Datagrid is bounded programmatically. I want to add/edit and delte records in the Data Grid. I am not able to update the recor to the table. Dataset is updated. Here is the code to populate Datagrid and Update. On Update button click, UpdateDetails() is called.

<pre
'="" populate="" data="" grid
="" private="" sub="" populatedatagrid(byval="" index="" as="" integer)
="" try
="" retreive="" by="" passing="" category="" id="" and="" save="" in="" set
="" dim="" i="" integer="Me.TblEmployeeTableAdapter.FillByCatId(Me.EmployeeDataSet.Tables("Employee")," index)
="" msgbox("rows="" found="" "="" +="" me.employeedataset.tables("employee").rows().count().tostring())
="" me.employeedatagrid.selectionmode="DataGridViewSelectionMode.FullRowSelect
" set="" the="" dataset="" datasource="" for="" me.employeedatagrid.datasource="Me.EmployeeDataSet.Tables("Employee")
" catch="" ex="" exception
="" messagebox.show(ex.message)
="" end="" try

="" sub

="" update="" details="" called="" on="" button="" event
="" updatedetails()
="" me.employeedataset.tables("employee").acceptchanges()
="" me.employeedataset.acceptchanges()
="" msgbox("updated="" status=" + i.ToString())
End Sub
' aLSO TRIED THIS, BY DRAGING THE TABLE INTO THE FORM AND RESULTED AS MY OWN CREATED DATAGRID
Private Sub UpdateBound()
Me.Validate()
Me.EmployeeBindingSource.EndEdit()
Me.EmployeeTableAdapter.Update(Me.EmployeeDataSet.Employee)
' Me.EmployeeataSet.AcceptChanges()
End Sub
' USER DELETING ROW EVENT OF DATAGRID
Private Sub EmployeeDataGrid_UserDeletingRow(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowCancelEventArgs) Handles AlbumsDataGrid.UserDeletingRow
If (MsgBox(" are="" you="" sure,="" want="" to="" delete="" record="" ",="" msgboxstyle.yesno,="" "delete="" record?")="MsgBoxResult.Yes)" then

="" msgbox("record="" deleted")
="" else
="" if
="" sub
<="" pre="">

When user selects a row, and Clicks Del key, UserDeletingRow event is thrown by the grid. I had handled that event & asking for confirmation. Even if the user says "No", the record is deleted at present from the grid. How to stop it. Currently no delte code is written.

1. How do I stop the Delete Action if the user selects No

2. Why is the Upadate not functioning - not saving in the DB.

3. How do I know if the user is adding new row. And How do I insert that row in DB.

4. These all operations need to be done just via Update button.


So, basically I need to Add/Delete/Edit records in DataGrid. Just have a Update button. I have enabled Add New, Delete, Modifiy in Datagrid. Please guide me as what wrong I am doing & what chamges/implementationes need to be done. I don't know how to bind data by default by running such type of query & passing parameter, so have done it programmatically.


Please help me friends. I looked a lot on net, but couldn't find proper solution for my needs.

Any help is appreciated.



Thanks

Terry

AnswerRe: Updating a Database via Datagrid Problem Pin
Kschuler8-Aug-07 8:01
Kschuler8-Aug-07 8:01 
GeneralRe: Updating a Database via Datagrid Problem Pin
Trupti Mehta8-Aug-07 21:22
Trupti Mehta8-Aug-07 21:22 
GeneralRe: Updating a Database via Datagrid Problem Pin
Kschuler9-Aug-07 2:43
Kschuler9-Aug-07 2:43 
AnswerRe: Updating a Database via Datagrid Problem Pin
shreekantk26-Feb-09 22:38
shreekantk26-Feb-09 22:38 
Questioncombobox with AutoCompleteMode Pin
aphei7-Aug-07 17:03
aphei7-Aug-07 17:03 
AnswerRe: combobox with AutoCompleteMode Pin
Nilesh Hapse7-Aug-07 20:51
Nilesh Hapse7-Aug-07 20:51 
GeneralInformation from Senthil.S for combobox with AutoCompleteMode Pin
Senthil S8-Aug-07 1:48
Senthil S8-Aug-07 1:48 
GeneralRe: combobox with AutoCompleteMode Pin
aphei8-Aug-07 15:37
aphei8-Aug-07 15:37 
AnswerReply combobox with AutoCompleteMode Pin
Senthil S8-Aug-07 1:35
Senthil S8-Aug-07 1:35 
GeneralRe: Reply combobox with AutoCompleteMode Pin
aphei8-Aug-07 15:39
aphei8-Aug-07 15:39 
QuestionUAC in Vista Pin
Kumaran21cen7-Aug-07 16:01
Kumaran21cen7-Aug-07 16:01 
AnswerRe: UAC in Vista Pin
Christian Graus7-Aug-07 16:58
protectorChristian Graus7-Aug-07 16:58 
GeneralRe: UAC in Vista Pin
Kumaran21cen7-Aug-07 18:07
Kumaran21cen7-Aug-07 18:07 
GeneralRe: UAC in Vista Pin
Christian Graus7-Aug-07 19:14
protectorChristian Graus7-Aug-07 19:14 
GeneralRe: UAC in Vista Pin
Colin Angus Mackay8-Aug-07 0:38
Colin Angus Mackay8-Aug-07 0:38 
GeneralRe: UAC in Vista Pin
Dave Kreskowiak8-Aug-07 3:26
mveDave Kreskowiak8-Aug-07 3:26 
QuestionSimple Firewall Pin
VIP-CoMmAnDo7-Aug-07 14:42
VIP-CoMmAnDo7-Aug-07 14:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.