PC Review


Reply
Thread Tools Rate Thread

Dtabinding and Update issues

 
 
Vincent Dalton
Guest
Posts: n/a
 
      28th Nov 2005
Hi All,

I have a typed dataset which contains several tables. The 3 that I am experiencing difficulty with are "CONTACTS", "ALL_ZIP_CODES" and "E_ZIP_CODES." The "CONTACTS" table is selfexplantory. The table "E_ZIP_CODES" is a subset of all ZIP codes that are in the "CONTACTS" table. The table "ALL_ZIP_CODES" consists of a complete listing of ZIP codes.

What I am trying to do is, when a user updates or adds a new contact, I search for the ZIP code in the "E_ZIP_CODES" table (dvSearch below). If the ZIP code is not in the table "E_ZIP_CODES" (i = -1 below), I want to add the ZIP code and city values from the "ALL_ZIP_CODES" datatable to the datatable "E_ZIP_CODES" so that I can update the "CONTACTS" table with the newly selected ZIP code. The new record is added to the datatable and all appears to be fine. However, when I try to update the "CONTACTS" datatable, I get the error "Failed to enable constraints"

TIA,

Vince

' Code to add new ZIP code
Dim dv As New DataView
Dim strSearch As String, i As Integer

With dv
.Table = dsMulti.Tables("ALL_ZIP_CODES")
.Sort = "ZIP_CODE"
.RowStateFilter = DataViewRowState.CurrentRows
End With

strSearch = cboE_ZIP_Code.Text.ToString

If strSearch = "" Then strSearch = txtE_ZIP_Code.Text.ToString

Try
Dim dvSearch As New DataView
With dvSearch
.Table = dsMulti.Tables("E_ZIP_CODES")
.Sort = "ZIP_CODE"
.RowStateFilter = DataViewRowState.CurrentRows
End With
i = dvSearch.Find(strSearch)
If i = -1 Then
Dim strCity As String
With dv
.Table = dsMulti.Tables("ALL_ZIP_CODES")
.Sort = "ZIP_CODE"
.RowStateFilter = DataViewRowState.CurrentRows
End With
i = dv.Find(strSearch)
strCity = "Test"
Dim rowNew As DataRow
rowNew = dsMulti.Tables("E_ZIP_CODES").NewRow
rowNew("ZIP_CODE") = strSearch
rowNew("CITY") = strCity
dsMulti.Tables("E_ZIP_CODES").NewRow.BeginEdit()
dsMulti.Tables("E_ZIP_CODES").Rows.Add(rowNew)
dsMulti.Tables("E_ZIP_CODES").AcceptChanges()
End If
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try

' Code to Update the CONTACTS table
sbrContacts.Panels(4).Text = "Saving record ..."
Try
curContacts.Refresh()
curContacts.EndCurrentEdit() ' Error here
With daContact.UpdateCommand
.Parameters("I_F_NAME").Value = txtFName.Text
.Parameters("I_M_NAME").Value = txtMI.Text
.Parameters("I_L_NAME").Value = txtLName.Text
.Parameters("I_CAOID").Value = cboCAO.ValueMember
.Parameters("I_LEVELID").Value = cboLevel.ValueMember
.Parameters("I_COMPANYID").Value = cboCompany.ValueMember
.Parameters("I_SITEID").Value = cboSite.ValueMember
.Parameters("I_SUB_TEAMID").Value = cboSubTeam.ValueMember
.Parameters("I_FUNCTIONID").Value = cboFunction.ValueMember
.Parameters("I_SUB_FUNCTIONID").Value = cboSubTeam_Function.ValueMember
.Parameters("I_SUB_FUNCTION_2_ID").Value = cboSubTeam_Function_2.ValueMember
.Parameters("I_POSITIONID").Value = cboPosition.ValueMember
.Parameters("I_BUS_PHONE").Value = txtBus_Phone.Text
.Parameters("I_BUS_PHONE_2").Value = txtBus_Phone_2.Text
.Parameters("I_BUS_MOBILE").Value = txtBus_Mobile.Text
.Parameters("I_BUS_OTHER").Value = txtBus_Other.Text
.Parameters("I_BUS_FAX").Value = txtBus_Fax.Text
.Parameters("I_BUS_FAX_2").Value = txtBus_Fax_2.Text
.Parameters("I_BUS_PAGER").Value = txtBus_Pager.Text
.Parameters("I_BUS_EMAIL").Value = txtBus_eMail.Text
.Parameters("I_NOTES").Value = txtNotes.Text
.Parameters("I_SSN").Value = txtSSN.Text
.Parameters("I_PAYROLL_NUM").Value = txtPayroll_Num.Text
.Parameters("I_GS_SERIES").Value = txtGS_Series.Text
.Parameters("I_GS_GRADE").Value = txtGS_Grade.Text
.Parameters("I_H_STREET_1").Value = txtH_Street_1.Text
.Parameters("I_H_STREET_2").Value = txtH_Street_2.Text
.Parameters("I_H_ZIP_CODE").Value = cboH_ZIP_Code.Text
.Parameters("I_H_PHONE").Value = txtH_Phone.Text
.Parameters("I_H_PHONE_2").Value = txtH_Phone_2.Text
.Parameters("I_H_MOBILE").Value = txtH_Mobile.Text
.Parameters("I_H_MOBILE_2").Value = txtH_Mobile_2.Text
.Parameters("I_H_PAGER").Value = txtH_Pager.Text
.Parameters("I_H_FAX").Value = txtH_Fax.Text
.Parameters("I_H_EMAIL").Value = txtH_eMail.Text
.Parameters("I_E_CONTACT").Value = txtE_Contact.Text
.Parameters("I_E_STREET").Value = txtE_Street.Text
.Parameters("I_E_STREET_2").Value = txtE_Street_2.Text
.Parameters("I_E_ZIP_CODE").Value = cboE_ZIP_Code.Text
.Parameters("I_E_PHONE").Value = txtE_Phone.Text
.Parameters("I_E_PHONE_2").Value = txtE_Phone_2.Text
.Parameters("I_E_PHONE_3").Value = txtE_Phone_3.Text
.Parameters("I_CONTACTID").Value = lblContactID.Text
End With
daContact.Update(dsMulti, "CONTACTS")
daContact.Fill(dsMulti, "CONTACTS")
sbrContacts.Panels(4).Text = "Ready"
Cursor.Current = System.Windows.Forms.Cursors.Default
Catch oraEX As OracleException
sbrContacts.Panels(4).Text = "Error"
Cursor.Current = System.Windows.Forms.Cursors.Default
MsgBox(oraEX.Message.ToString)
End Try

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Microsoft UPDATE Issues- Security Update KB960803 Failed caleprete60 Microsoft Dot NET 1 21st Nov 2009 06:47 PM
SP3 and Update Issues User Windows XP General 2 17th May 2008 09:20 PM
IE 6 issues and Windows Update Issues =?Utf-8?B?R2liYnNfU29u?= Microsoft Windows 2000 Windows Updates 4 29th May 2006 11:49 PM
Update issues =?Utf-8?B?ZGlyZWR1cA==?= Security Signatures 2 18th Mar 2006 06:04 PM
Update issues... =?Utf-8?B?YmJndW5uZXI=?= Spyware Discussion 1 2nd Mar 2006 04:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:37 PM.