Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET Database and Reporting > Editing and Updating Fields


Reply
 
Thread Tools Display Modes
  #1  
Old 02-12-2005, 06:03 PM
albert74 albert74 is offline
Newcomer
 
Join Date: Dec 2004
Posts: 6
Default Editing and Updating Fields


I have the following fields, controls and datagrid in a form (frmInfo):
txtIdentNo
txtRev
txtTitle
txtRemarks

InfoGrid (Datagrid)

cSave, cUpdate, CDelete, cExit (command Buttons)

txtIdentNo and txtRev are both PRIMARY Keys.

I have the following question:
When I click on the cUpdate, I am UNABLE to edit or update the txtIdentNo and txtRev even though I have key-in the new txtIdentNo and txtRev in the fields???

I understand that fields that belong to the Primary Keys cannot be edited/updated but is there any work-around that allow me to edit or duplicate the other fields that ties to the txtIdentno and txtRev.

Any suggestions is appreciated.
Reply With Quote
  #2  
Old 02-13-2005, 09:49 AM
MKoslof's Avatar
MKoslof MKoslof is offline
Cum Grano Salis

Retired Moderator
* Guru *
 
Join Date: Jul 2002
Location: Baltimore, Maryland
Posts: 14,636
Default

Can we see the code you are using for this?
__________________
"Artificial Intelligence is no match for natural stupidity." ~unknown
Reply With Quote
  #3  
Old 02-14-2005, 07:36 AM
albert74 albert74 is offline
Newcomer
 
Join Date: Dec 2004
Posts: 6
Default

Private Sub InfoGrid_DoubleClick(ByVal sender As System.Object, ByVal ne As System.EventArgs) Handles InfoGrid.DoubleClick

Dim cConnect As CDatabaseConnection

cConnect = New CDatabaseConnection(objConfig.Server(), objConfig.UserID(), objConfig.Pwd(), objConfig.DBType())
cConnect.Connection.ChangeDatabase(objConfig.DB())


Dim objInfo As New cInfo()
If objInfo.GetInstance(cConnect.Connection, "Info", InfoGrid.Item(InfoGrid.CurrentCell.RowNumber, 0), InfoGrid.Item(InfoGrid.CurrentCell.RowNumber, 1)) Then

txtIdentNo.Text = objInfo.IdentNo
txtRev.Text = objInfo.Rev
txtTitle.Text = objInfo.Title
txtRemarks.Text = objInfo.Remarks

cUpdate.Enabled = True
cSave.Enabled = False
cDelete.Enabled = False
cExit.Enabled = False

End If

cConnect.Close()
cConnect = Nothing

End Sub



Private Sub cUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cUpdate.Click


Dim cConnect As CDatabaseConnection

Try
cConnect = New CDatabaseConnection(objConfig.Server(), objConfig.UserID(), objConfig.Pwd(), objConfig.DBType())
cConnect.Connection.ChangeDatabase(objConfig.DB())

Dim objInfo As New cInfo()

objInfo.IdentNo = "Info"
objInfo.Rev = txtRev.Text
objInfo.Title = txtTitle.Text
objInfo.Remarks = txtRemarks.Text

If objInfo.Update(cConnect.Connection, "Info", txtIdentNo.Text) Then

End If

Catch ex As Exception

MsgBox(ex.Message)
cConnect.Close()
cConnect = Nothing

End Try

If Not cConnect Is Nothing Then
cConnect.Close()
cConnect = Nothing
End If

End Sub
Reply With Quote
  #4  
Old 02-15-2005, 04:07 AM
albert74 albert74 is offline
Newcomer
 
Join Date: Dec 2004
Posts: 6
Default

can anyone advise what is wrong with my code that prevent me from updating the txtIdentNo?? Thanks,
Reply With Quote
  #5  
Old 02-15-2005, 04:41 PM
MKoslof's Avatar
MKoslof MKoslof is offline
Cum Grano Salis

Retired Moderator
* Guru *
 
Join Date: Jul 2002
Location: Baltimore, Maryland
Posts: 14,636
Default

What is CDatabaseConnection? Where do you define the definition for this class?
__________________
"Artificial Intelligence is no match for natural stupidity." ~unknown
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->