So: Instead of using
if (textBox6.TextLength < 4)
label12.Text="PIN should have only 4 digits";
if (textBox6.TextLength > 4)
label12.Text = "PIN should have only 4 digits";
Convert the number to an integer, using TryParse:
int PIN;
if (!int.TryParse(textBox6.Text, out PIN) || PIN < 1000 || PIN > 9999)
{
label12.Text = "Invalid PIN!";
}
else
{
Then transfer the integer to SQL.
But... a couple of things:
1) Don't do it like that! Do not concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead.
2) Please don't use VS default names for everything: it makes it a lot harder to work out what is going on, particularly when you come cak to change it in a months time. You might remember today that textBox6 is the PIN number, but you won't in six weeks time!