Results 1 to 2 of 2

Thread: howto limit records in sql express database

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    46

    howto limit records in sql express database

    i am using visual studio 2010 with vb environment, i have a windows form app that connects to a local sql express database, i am wanting to limit the amount of records that can be added to a table to 100, how would i go about it, i am using the standard navigation buttons to add records.

    the table has a id field that is autogenerated and auto increment of 1

    thanks.

  2. #2
    Fanatic Member EntityX's Avatar
    Join Date
    Feb 2007
    Location
    Omnipresence
    Posts
    798

    Re: howto limit records in sql express database

    I recently posted the code for an ADO.NET tutorial. There's a zip file there if you want to use it. If you load the contents of your database into a DataSet as is done in that tutorial you should be able to figure out how to do what you're trying to do by studying that. Look at the btn_Add_Click and the btn_Last_Click Subs. From studying the code there you should be able to figure things out. You would only add a new record if ds.Tables(0).Rows.Count - 1 is below 100 or get rid of the -1 if you like and make whatever adjustments are necessary. You can test things by using a label to display exactly what that number is using .ToString after Count.

    http://www.vbforums.com/showpost.php...50&postcount=2
    Make as many mistakes as you can as quickly as you can. We want to make sure that we make a great enough number of mistakes in a given amount of time so that we can be successful.

    "Persistence is the magic of success." Paramahansa Yogananda

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width