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.
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