|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Confussing error .. help needed(part of sub ) Orig_Accounts = GetSQLDataSet("EXEC BossData.dbo.SQL2005_ORIGACCOUNTS", "TBL_OrigAccounts") ' Set Primary Keys SearchKey(0) = Orig_Accounts.Tables("TBL_OrigAccounts").Columns("tblOA_Licence") SearchKey(1) = Orig_Accounts.Tables("TBL_OrigAccounts").Columns("tblOA_AccountID") Orig_Accounts.Tables("TBL_OrigAccounts").PrimaryKey = SearchKey (end part of sub ) I then call SearchRecord using LicenceNumber & "001" to display the 1st account for that licence number. this all works fine. I load all the account id's ( 001,002 003 etc ) into a combobox using the sub LoadcmboAccountID. The idea is that the operator can use the combobox and select an account id it will display that record. However when the use selects an Id and i call the SearchRecord(sLicence, cmboAccountID.Text) sub , SLicence being the licence number and cmboAccountID.Text being the selected ID from the combo list. I keep getting this error Column 'tblOA_Licence, tblOA_AccountID' is constrained to be unique. Value '217514, 005' is already present. and i dont understand why... the sub works fine when the form is loaded, but as soon as you try and use it a second time you get that error. Stepping through the code it is causing an error at the Manager.Position = ACTIVEROW line, any ideas why ? SUB Private ACTIVEROW As Integer = 0 Private SearchRow As DataRow Dim FindMatch(1) As Object Private Sub SearchRecord(ByVal Licence As String, ByVal AccountID As String) Try FindMatch(0) = Licence FindMatch(1) = AccountID SearchRow = Orig_Accounts.Tables("TBL_OrigAccounts").Rows.Find(FindMatch) ACTIVEROW = CInt(SearchRow("idCol").ToString) If ACTIVEROW > 0 Then LoadControls(ACTIVEROW) Manager.Position = ACTIVEROW End If Catch ex As Exception Console.WriteLine(ex.Message) End Try End Sub Private Sub LoadcmboAccountID() SQL_COMMAND.CommandText = "Select TblOA_AccountID from Bossdata.dbo.OriginatingAccounts where tbloa_licence = '" & sLicence & "' Order by Tbloa_AccountId" SQL_COMMAND.Connection = BOSSSQLCONNECTION SQL_DATAREADER = SQL_COMMAND.ExecuteReader Do While SQL_DATAREADER.Read If SQL_DATAREADER.GetString(0) > cmboAccountID.Text Then cmboAccountID.Items.Add(SQL_DATAREADER.GetString(0)) End If Loop End Sub Peter Newman wrote:
> On casual inspection of your code, I can't see what might be causing> Column 'tblOA_Licence, tblOA_AccountID' is constrained to be unique. Value > '217514, 005' is already present. > that exception. But apparently you have a unique constraint on the License and AccountID columns of your table and for some reason you are inserting another record with that same combination of License and AccountID. You will have to figure out why you are inserting a new record with those same values.
Can anyone help with proper use of operator CType in VB.net?
Data Source error... help!? Getting msgbox to appear on top of splashscreen VB.net 2005 Autosaving? in VB2005 express OOP Confused Help on DataSets Can you not do this? PrintPreview control does not print CPU Temperature I can't seem to find BorderStyle |
|||||||||||||||||||||||