Is It Necessary To Use Primary Key With Access Database --> How To Prevent Displaying Default Primary Key

I had to create a default primary key (numbered from 1 to N) column with my Access database in order for my application to work. Is there an easy way to make my table visible without displaying the primary key How do I do this Please give me information by posting the exact sequence of button clicks, things to type, etc that I must perform

My component tray has a BindingNavigator, TableAdapter, Binding Source, and a DataSet.

 




Answer this question

Is It Necessary To Use Primary Key With Access Database --> How To Prevent Displaying Default Primary Key

  • Haggerty

    Hi!

    Well I've no idea what are you talking about. In your question you asked for mechanism to display the table without primary key and thats what I suggested. I didn't know that you wanted to add and delete rows as well. As far working of mechanism is concerned it works perfectly and is more efficient in a way that it even won't fetch the data for unwanted column so reducing the network load, which won't be the case if you load in memory full table via table adapter and hide the column in grid.

    The only thing I forgot to mention was when you see the message "Updating queries cannot be automatically......" just click no and it will do the trick.

    Anyways you got what you wanted it doesn't make any difference whether it comes from me or some one esle.

    cheers

    Sohail.



  • Speedipus

    Christopher...Create your dataset just like it was suggested and select the primary key as a part of your SQL statement....This will allow the wizard to create the proper update and insert statements for you. (Your dataset will contain the primary key)

    How are you displaying your data on the form Form View I would guess...If thats the case then simply delete the label and textbox of the primary key from your form. If it is a datagridview, delete the primary key column from the columns collection of the dgv!



  • Almero

    When I do either of your suggestions, it didn't work. In both cases (deleting "ID," or unselecting ID), VB prompts me with the following question:

    Updating queries cannot be automatically generated because your SELECT query does not include some primary key columns. Do you wish to add primary key

    If you answer yes VB adds the same primary key to the SELECT statement. If I answer "no" and run the application I will get unrecoverable build errors.

    Sohail Iqbal wrote:

    Hi!

    Goto Dataset Design view, right click the tableadapter you want to edit and then select "configure". This will start the cofiguration wizard. Type in the query for the columns you want to display or use "Query Builder" button in the right hand corner to build the query for only those columns that you want to display. Click Next, Next and Finish and you are done.

    cheers

    Sohail.



  • dariakus

    Although you never have to "display" it, every table in every db should utilize a primary key. It is the single most unique way to identify a row in a given table. The wizards in VS have a difficult time (won't generate) creating the proper SQL statemnts if you don't select the primary key as apart of the query...(or worse if the table does not have a pk)

  • Mathias Vestergaard

    I fixed it thanks everyone! I was able to just click on the grid and edit columns.

  • IanHurrell

    IF you are using the wizards you must select a primary key....

    Once you have the data in a table in a dataset you can choose how to display the data to the user whether it be in a datagrid view or in a form view...in either case its when you setup the user inteface is when you decide what fields the user will have access to....Just because your dataset has 25 fields does not mean that you have to display all 25 to the user!



  • AdamDev

    DMan1, what specifically (please give details in a step-by-step process telling me what buttons to push etc) do I do On the face of it, Sohail Iqbal's post doesn't seem to work!

    My component tray has a BindingNavigator, TableAdapter, Binding Source, and a DataSet.



  • S.W. Lambert

    Hi!

    Goto Dataset Design view, right click the tableadapter you want to edit and then select "configure". This will start the cofiguration wizard. Type in the query for the columns you want to display or use "Query Builder" button in the right hand corner to build the query for only those columns that you want to display. Click Next, Next and Finish and you are done.

    cheers

    Sohail.



  • Is It Necessary To Use Primary Key With Access Database --> How To Prevent Displaying Default Primary Key