I enter a name in textbox eg. "John" and save it in the database which it does, then i again enter "John" which it does not save. But if i enter "john", it saves this again... I need it to not save the john and vice-versa.
ok so this is the textbox which is quiet normal:
<asp:TextBox ID="TextBox2" runat="server" Width="80%" BorderColor="Black"
MaxLength="127"></asp:TextBox>
and here is the code:
int k= 0
SqlConnection dataConnection = new SqlConnection();
dataConnection.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlCommand dataCommand =
new SqlCommand("select Name from Groups", dataConnection);
ArrayList names = new ArrayList();
dataConnection.Open();
SqlDataReader rdr = dataCommand.ExecuteReader();
while (rdr.Read())
{
names.Add(rdr.GetString(0));
}
dataCommand.Dispose();
dataConnection.Dispose();
//to check if name already used..
for (int i = 0; i < names.count; i++)
{
if (Name != (string)names[i])
{
k = 1;
}
else
{
Label1.Text = "Name is already present";
Label1.Visible = true;
k = 0;
break;
}
}
if (k == 1)
{
Insertname();
}