Record will not save to Table in SQLite

BPak

Active Member
Licensed User
Longtime User
I am creating a program that uses the SQLite database a lot and have come across a problem where the HorseFileName TABLE is Created but Data will not save to the HorseFileName Table.

I have put the code from the main app I am creating into a small prog to test it for errors but just can not see where I have it wrong as it runs through the debug line by line until the cmd.ExecNonQuery and then drops through to the error.

Maybe someone may see something I do not see in my code.

Thanks for any help.

It is this sub that it stops working in the error trap.

B4X:
Public Sub [B]SaveHorseListData[/B]
   ErrorLabel(HseListErr)
   
   ' create parameters
   cmd.AddParameter("RaceID")
   cmd.AddParameter("TAB")
   cmd.AddParameter("HorseName")
   cmd.AddParameter("E")
        .....
        .....

   cmd.CommandText = "INSERT INTO " & HorseFileName & " (HID, RaceID, TAB, HorseName, E, Cty, ThisForm, " & _
      "Barrier, NewBar, Weight, FWD, WDOds, FWW, WWOds, FSD, SDOds, FSW, SWOds, AdjRate, HorseAge, HorseType, " & _
      "HorseSex, HorseTrainer, HorseTrainerLoc, Jockey, Allow, QTABJock, Career, Runs, Ws, Ps, APIs, " & _
      "CurAPIs, WinDist, ThisDist, ThisCourse, Fast, Good, Dead, Slow, Heavy, FUp, SUp, ThisDistPC, " & _
      "ThisCoursePC, FastPC, GoodPC, DeadPC, SlowPC, HeavyPC, FUpPC, SUpPC, DLS, Breed, Owner, Silks, " & _
      "RunsBack, RBLetUp, WRPos, SRPos, PcePos, APIPos, PsPos, WsPos, DDist, DWgt, HPace, BlkBk, FS) " & _
      "VALUES (null, @RaceID, @TAB, @HorseName, @E, @Cty, @ThisForm, @Barrier, @NewBar, @Weight, @FWD, @WDOds, " & _
      "@FWW, @WWOds, @FSD, @SDOds, @FSW, @SWOds, @AdjRate, @HorseAge, @HorseType, @HorseSex, @HorseTrainer, " & _
      "@HorseTrainerLoc, @Jockey, @Allow, @QTABJock, @Career, @Runs, @Ws, @Ps, @APIs, @CurAPIs, @WinDist, " & _
      "@ThisDist, @ThisCourse, @Fast, @Good, @Dead, @Slow, @Heavy, @FUp, @SUp, @ThisDistPC, @ThisCoursePC, " & _
      "@FastPC, @GoodPC, @DeadPC, @SlowPC, @HeavyPC, @FUpPC, @SUpPC, @DLS, @Breed, @Owner, @Silks, @RunsBack, " & _
      "@RBLetUp, @WRPos, @SRPos, @PcePos, @APIPos, @PsPos, @WsPos, @DDist, @DWgt, @HPace, @BlkBk, @FS)"

   cmd.SetParameter("RaceID", RHse.RaceID)
   cmd.SetParameter("TAB", RHse.TAB)
   cmd.SetParameter("HorseName", RHse.HorseName)
   cmd.SetParameter("E", RHse.E)
   cmd.SetParameter("Cty", RHse.Cty)
   cmd.SetParameter("ThisForm", RHse.ThisForm)
        ....
        ....

   cmd.ExecuteNonQuery

   Return
   
HseListErr:
   Msgbox("Adding Horse to Database failed!", "Horse Error", cMsgboxOK, cMsgboxHand)
   Return
End Sub

The full code is attached as I abbreviated the above because of the size of code.

Had problems with the other table RaceFileName originally but found the problems I had there and it now is working OK.

I have been using sqliteadmin program to examine the tables for input and so verifying if data has been added.
 

Attachments

  • Tstdb.zip
    4.6 KB · Views: 218

mjcoon

Well-Known Member
Licensed User
My suggestion would be not to use error handlers when debugging.

When I commented it out in your code I got the attached very clear error message that shouold help you to sort out the problem, which I think has nothing to do with the code snippet that you cited.

Mike.
 

Attachments

  • New Bitmap Image.JPG
    New Bitmap Image.JPG
    16.4 KB · Views: 205

BPak

Active Member
Licensed User
Longtime User
My suggestion would be not to use error handlers when debugging.

Thanks Mike.

Did not know that about the Error handlers during debug!

I had AdjRate and it should have been AdjRte.

Read it numerous times and missed seeing the spelling error.

:sign0060:
 
Top