This article will show you how you can create registration
form in c#.net with SQL database. So in this article I have used Ms SQL server database.
In this I will save the user login detail into sql table by using c#.net
First we will create a windows application registration form.
First we will create a windows application registration form.
Above form is a custom design registration from and you can check how to create a custom registration from in windows application.
On submit button add the below code.
private void btnSubmit_Click(object sender, EventArgs e)
{
string connection = @"Server=LAPTOP-EVJEKV38\SQLEXPRESS;
Database=TestDB; Integrated Security=True";
SqlConnection con = new SqlConnection(connection);
try
{
string query = "Insert into
UserLogin(Name,EmailId,LoginId,Password) Values('" + txtName.Text + "','" + txtEmailId.Text + "','" + txtLoginId.Text + "','" + txtpassword.Text + "')";
SqlDataAdapter da = new SqlDataAdapter(query, con);
con.Open();
da.SelectCommand.ExecuteNonQuery();
MessageBox.Show("Account created
successfully..");
ClearData();
}
catch
{
MessageBox.Show("Error occured...");
}
finally
{
con.Close();
}
}
//Clear data after submit
private void ClearData()
{
txtName.Text = "";
txtEmailId.Text = "";
txtLoginId.Text = "";
txtpassword.Text = "";
txtConPassword.Text = "";
}
|
Here is above code I have saved the data into the database. After saving the record a message will show and later all the records have been cleared. Now let’s run the application and check the output. For this I have created a table named as UserLogin.
In
above code u need to change the connection string as per your server database
and change the query as per you need.
Now add the detail into form and click on submit.
Now check the data base for detail
DOWNLOAD
0 comments:
Please let me know your view