Problems with primary keys

  • I have an vb application which writes to a SQL 7 database. There are 2 databases, live and test, which appear to be identical.

    The problem I am having is updating a record in one of the tables using the primary key (AllocationCode). The SQL statement that is used is:

    UPDATE tblAllocations SET tblAllocations.AllocationUPN6 = '" & strUPN6 & "', tblAllocations.AllocationWeight = " & dblWeight & " " & _

    WHERE (((tblAllocations.AllocationCode)=" & lngAllocationCode & "))

    where strUPN6, dblWeight and lngAllocation code are parameters that are passed in to the calling function.

    When this is ran against the test database it works but when we try against the live database it fails, but does not error. However, the query works against the live database when running the query through query analyzer.

    Does anyone have any thoughts/ideas? If so could you please email them to lee.noble@mi-king.co.uk

    Many Thanks

    Lee Noble

  • A few thoughts here.

    1) Have you stepped thru the VB to get the exact string it is passing? Could be the string contains a where criteria that it shouldn't that causes no matches thus no error and technically did not fail even if not expected.

    2) Do you have any kind of error trapping in your VB code? A common mistake in VB programming is to use On Error Resume Next which really should only be used exactly when a known situation is needed and right after an On Error Goto 0 should be issued, otherwise send to an error handling process. However the mistake is made (and yes I forgot numerous times before I got it down pat myself) that On Error Resume Next is issued at the top and nothing is done otherwise so any error inside the code that was not expected is able to slip past. If you are using On Error Resume Next adjust as I stated or remove for testing, you may just be missing your error do to an honest mistake.

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

  • Do you have any triggers associated with this Update because at times if the trigger fails then I have come accross situations where the code seems to be working fine but changes do not get reflected in the database. In such a case one has to use exactly the same data to debug the problem well.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply