Hello! Anyone could tell me how to set the limit of a certain column to accept 10 the same inputs only. I have a table named Date and I want to limit its content for the same inputs to 10 only cause 10 person only can have the same date. Thanks and God Bless. :D

just check the :- COUNT(your column name of table).. // in sql

for datagridview check DataGridView.Rows.Count

if count is > 10 then dont let user enter any data

>Anyone could tell me how to set the limit of a certain column to accept 10 the same inputs only.

Sorry, I'm not quite following the problem. Correct me if I'm wrong. Do you want to update a specific column value of this table?

@adatapost - the problem is a certain column should only accept 10 the same inputs. For Example, an applicant for entrance examination will be scheduled on a certain date but only 10 person can be scheduled for that day. :D

Sorry again (; Post your code here and someone will help you.

sorry.. i misunderstood there

here is a query that will give u how many time a row or (column value) occurs in a table.

SELECT  first_name
,       COUNT(first_name) AS Total
FROM    dbo.fdguest_master
GROUP BY first_name
HAVING  ( COUNT(first_name) > 1 )

replace first_name with your date field

Thank you very much! I hope it'll work for me. Actually the SELECT statement would be manipulated using VB.NET as my front end. Would you mind to teach me how to insert this statement on VB.NET, I am using OLEDB and a message box will appear saying "Date is Full" when > 10. Thanks! God Bless. (I'm sorry for disturbing you. )

Great! So my understanding that you want to restrict 10 rows per user/date. Isn't it?

hi write below code at some button's click event:

Dim cn As OleDbConnection
        Dim cmd As OleDbCommand

        cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Database1.mdb;")
        Dim strQ As String = String.Empty

        strQ = "SELECT  COUNT(letter) AS Total FROM tbl GROUP BY letter HAVING (COUNT (letter) > 1)"

        cmd = New OleDbCommand(strQ, cn)

        Dim answer As Integer

        cn.Open()
        answer = Integer.Parse(cmd.ExecuteScalar().ToString())
        cn.Close()

        If answer >= 10 Then
            MessageBox.Show("Limit Reached")
        End If

Here replace the "letter" with your date field name

Thank you very much! God Bless. :D

Great! So my understanding that you want to restrict 10 rows per user/date. Isn't it? -- Yeah right! The thing is I have a textbox where in the value of my "Date" column will be compared to the value being inputted by the textbox and if the column already has 10 the same values that's the time that "Limit reached" will be displayed. I'm so sorry. Thanks and God Bless. :D

Thank you very much and I do really appreciate the effort but I think I'm missing out on something. It's just that, Great! So my understanding that you want to restrict 10 rows per user/date. Isn't it? -- Yeah right! The thing is I have a textbox where in the value of my "Date" column will be compared to the value being inputted by the textbox and if the column already has 10 the same values that's the time that "Limit reached" will be displayed. I'm so sorry. Thanks and God Bless. :D

Sorry, my internet connection is kinda malfunctioning. The last 2 posts excluding this are wrong. Sorry. :(

No problem. Double post will be deleted by moderator team. Please mark this thread as solved if you have found an answer to your question and good luck!

I hope this is my final question to you regarding this topic. The thing is I have a textbox where in the value of my "Date" column will be compared to the value being inputted by the textbox and if the column already has 10 the same values that's the time that "Limit reached" will be displayed. I'm so sorry. Thanks and God Bless. Please.... :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.