Hello friends,
well i have really very big problem . i m using mysql database and windows Application i just want to know that when i m inserting same student name on that time it would be give me Message like "the Student name is Already Exits".. is it possible or not if yes than let me know wht is the code for it...
thanks in Advance
Name Khan
Loading

Naeem KhanPosted Feb 2, 2010, 7:59 AM
Still i m not understanding whats going on this code..... please tell me in easy way if you have any application or demo than let me know or try to send me i really need ur help...
thanks in Advance
Santhosh NPosted Feb 1, 2010, 4:09 AM
string connString = "SERVER=" + server + ";" +
"DATABASE=mydatabase;" +
"UID=testuser;" +
"PASSWORD=testpassword;";
MySqlConnection cnMySQL = new MySqlConnection(connString);
MySqlCommand cmdMySQL = cnMySQL.CreateCommand();
MySqlDataReader reader;
cmdMySQL.CommandText = "select * from mycustomers where username = '" + txtUser.Text + "'";
cnMySQL.Open();
reader = cmdMySQL.ExecuteReader();
if (reader.Read())
{
//user exists and perform a validation message here
}
else
{
//user does not exist
}
cnMySQL.Close();