How to check if I have the username in database C#? -
this question has answer here:
i'm new in c# , databases. made database in add data person. actually, data person create account. checked if email have email structure , checked if password same retype password. here have code:
if (pass.text != rpass.text) { messagebox.show("password don't match!"); return; } string emailcheck = email.text; bool valid = false; int count_dot = 0; (int = 0; < emailcheck.length; i++) if (emailcheck[i] == '@') valid = true; else if (emailcheck[i] == '.') count_dot++; if (valid == false || count_dot == 0) { messagebox.show("invalid email!"); return; } con = new sqlconnection(@"data source=maria-pc;initial catalog=account;integrated security=true"); con.open(); cmd = new sqlcommand("insert [dbo].[cont1] (username,password,first_name,last_name,birth_year,email,work_type) values (@username,@password,@first_name,@last_name,@birth_year,@email,@work_type)", con); cmd.parameters.add("@username", username.text); cmd.parameters.add("@password", password.text); cmd.parameters.add("@first_name", first_name.text); cmd.parameters.add("@last_name", last_name.text); cmd.parameters.add("@birth_year", datetime.parse(birth_year.text)); cmd.parameters.add("@email", email.text); cmd.parameters.add("@work_type", work_tpye.selecteditem.tostring()); cmd.executenonquery(); con.close();
so, want check, before add in database, if have username in database. have idea have do, don't know how do.
have @ merge command. there many other tutorials on web.
Comments
Post a Comment