in

System.Data.SQLite

An open source ADO.NET provider for the SQLite database engine

Primary Key has to be a number and first row?

Last post 02-15-2007 12:43 PM by jnatran. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 02-13-2007 1:58 PM

    Primary Key has to be a number and first row?

    Hi, my table is as follow

    COLOR

    PK_Name: string -> primary key

    Value: string

    And this one has the same problem

    COLOR

    Value: string

    PK_Name: int -> primary key

    When I drag this table into the designer, the Insert, Delete, and Update command are not generated.  It works fine for primary key as int and the first field like

    COLOR

    PK_Name: int -> primary key

    Value: string

    Please help, thanks!

  • 02-13-2007 2:09 PM In reply to

    Re: Primary Key has to be a number and first row?

    Can you give me the exact table definition (a CREATE TABLE statement and any indexes you may have on it).  Also what version of the provider are you using?

    Robert

     

  • 02-13-2007 4:11 PM In reply to

    Re: Primary Key has to be a number and first row?

    Robert, here is the table with string primary key:

    CREATE TABLE COLOR ( PK_Name[VARCHAR2(50)], Value[VARCHAR2(50)], primary key (PK_Name));

    And here is the table with an integer primary key that's not the first field:

    CREATE TABLE Menus ( PK_Name[VARCHAR2(50)], [Order][INTEGER], FK_PAGE_TopLevel[VARCHAR2(50)], FK_PAGE_Welcome[VARCHAR2(50)], FK_PAGE_Splash[VARCHAR2(50)], FK_PAGE_Audio[VARCHAR2(50)], volUpLiPoint[INTEGER], volDnLiPoint[INTEGER], Menus_Id[INTEGER], primary key (Menus_Id));

    Beside the problem with not generating Insert, Update, Delete command, the relationship is not created between Menus table and MenuPanels below:

    CREATE TABLE MenuPanels ( PK_Name[VARCHAR2(50)], captionText[VARCHAR2(50)], FK_TextBox_Caption[VARCHAR2(50)], virtualLiPoint[INTEGER], feedbackStatusPoint[INTEGER], feedbackStringPoint[INTEGER], FK_TextBox_Feedback[VARCHAR2(50)], FK_BitmapGroups_panelBmps[VARCHAR2(50)], FK_PAGE_JumpTo[VARCHAR2(50)], Menus_Id[INTEGER] CONSTRAINT fk_Menus_Menus_Id REFERENCES Menus(Menus_Id) ON DELETE CASCADE, primary key (PK_Name));

    The provider is ".NET Framework Data Provider for SQLite" version 3.3.12, I just downloaded it last week.

    Thanks,

  • 02-13-2007 4:28 PM In reply to

    Re: Primary Key has to be a number and first row?

    Forgot, I don't have any indexes.  If I just move the Menus_Id to the front for the Menus table then Insert, Update, and Delete are all there:

    CREATE TABLE Menus2 ( Menus_Id[INTEGER], PK_Name[VARCHAR2(50)], [Order][INTEGER], FK_PAGE_TopLevel[VARCHAR2(50)], FK_PAGE_Welcome[VARCHAR2(50)], FK_PAGE_Splash[VARCHAR2(50)], FK_PAGE_Audio[VARCHAR2(50)], volUpLiPoint[INTEGER], volDnLiPoint[INTEGER], primary key (Menus_Id));

  • 02-13-2007 5:09 PM In reply to

    Re: Primary Key has to be a number and first row?

    I'll try and recreate this on my side and see what I get.

    Robert

     

  • 02-15-2007 12:43 PM In reply to

    Re: Primary Key has to be a number and first row?

    Did you find anything Robert?  I did some digging into the code myself, but I am not too familar with the data provider structure.  I noticed that I could get the Insert, Update, Delete queries by calling the SQLiteCommandBuilder class directly.  Some parameters are wrong though, like in the COLOR table, the Update query look like this:

    UPDATE [COLOR] SET [PK_Name] = @param1, [Value] = @param2 WHERE (([PK_Name] = @param3) AND ((@param4 = 1 AND [Value] IS NULL) OR ([Value] = @param5)))

    Howerver, param1 _nullable is set to true; shouldn't that be false because PK_Name is a primary key?  Also SQLiteKeyReader returns empty for COLOR table (no key?)  However, I still cannot find the reason why a INTEGER primary key works fine, and a VARCHAR2(50) doesn't work.

Page 1 of 1 (6 items)
Powered by Community Server (Commercial Edition), by Telligent Systems