Link to home
Start Free TrialLog in
Avatar of technicaltrader
technicaltraderFlag for United States of America

asked on

How to create an automatic row numbering database in SQL Server Compact

Couple parts to this question so I will list them all as I believe they would be related in the problem to be solved. If not all related I would like help with the first question to start.

First:
Trying to create a automatic row numbered database in SQL Server Compact. Now I can create the numbering, but is really odd how it operates. When you add a new row it numbers it in negatives (IE: -1 -2 -3 ...etc). When you save your data and re-open the database it is numbered properly and in positives.

Second:
When I delete rows, the numbering of the rows doesn't update. So if I have row 1 2 3 4 and 5 and delete row 2 and 4, save my work and re-open the database I now have 1 3 and 5. Would like it to update the numbering structure when rows are deleted.

Third:
I can click on "Add new row" several times and it does, Would like to only add a new row and no other rows can be added until the current "New Row" is populated.

I am using Visual Basic 2008 Express to build this database in SQL Server Compact. The database works very nice for me as it is but would like to figure out how to number this database in an efficient manner.

My process for creating and numbering this database:

          1. "File" and then click "New Project"
          2. Under "Project"  I click "Add New Item"
          3. I select "Local Database" in the "Add New Item" window
          4. In the "Database Explorer" I right click "Tables" and click on "Create Table"
          5. I name my "Column" and in "Data Type" I select either "bigint" or "int" and change the Default Value of "Identity" to True and "IdentityIncrement" and "IdentitySeed" to "1" .
          6. Add the rest of my data columns

That is how I create my automatically numbering database but operates in a quirky manner. Hope this isn't overly detailed. Will provide additional details if needed. Thanks in advance.
           


SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of technicaltrader

ASKER

OK. Now that I think about what you have pointed out that makes complete logic. Understood!

I will simplify this question then.

When I click to "AddNewItem" I can click it many times and create many new rows in the database. How can I limit this click to "AddNewItem" to create a new row, and another new row can not be created until the current row cells are populated? Possibly throws up a message of something like: "Current data is not complete" or something. Just thinking aloud now.

I like how this program is written. It is my first development. I am using this for my market trading. I have plans for other tools as well so teaching myself programming in VB. I am now just taking care of all the nuances that I don't like within this program. (Small details that makes it better)

Hope that makes sense.

Thanks again...
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Well to answer the question; "Do you really plan to use it on Pocket PC? Answer is "No" and as many red flags that were in my face, my new discovery of using SQL and Visual Basic again teaches me a new lesson. Fortunately I look to lessons such as this as "Constructive".

I wanted to use Express, not Compact. I failed to recognize the word "Compact". Being a bit naive and very new it doesn't surprise me. Now on my new quest of adding a database as express. I have become very efficient at starting a new database. Trouble is, I only see "Local Database" in "Add New Item" and comes up as "Compact". Express is loaded on this computer. Apparently I have new discoveries to unfold. If I can't figure it out, it will be time to start a new question. LOL...

Thanks to each of you as all comments taught me something!
...and as I dig around about compact 3.5, it seems that this will work fine for the application as it is to be used. Believe I am on the right path at least for now. Again, you all directed me in a way with this question that I have progressed because of all of you. Again. I thank you!...
You are welcome, technicaltrader. I would recommend to download SQL Server Management Studio Express. It will allow easy database creation and SQL queries testing. If you need more features then you should buy SQL Server Developer version - cheap (not sure but around $50) and complete for development.
Sorry for duplicate recommendation of SQL MSE :-). But it is free...