How-to: Create an SQL server db, connect to it in Visual Studio, fill with data

Channel:
Subscribers:
65
Published on ● Video Link: https://www.youtube.com/watch?v=ZLcEzwvWiSc



Duration: 3:35
2,177 views
10


using System.Data.SqlClient;

protected void ButtonReg_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString =
"Data Source=.\\SQLEXPRESS;" +
"Initial Catalog=GalleryDataBase;" +
"Integrated Security = true;";
conn.Open();

String query = "INSERT INTO dbo.UserData (Name,Email,Password) VALUES (@username, @email, @password)";

SqlCommand command = new SqlCommand(query, conn);
command.Parameters.AddWithValue("@username", TextBoxUserName.Text);
command.Parameters.AddWithValue("@email", TextBoxEmail.Text);
command.Parameters.AddWithValue("@password", TextBoxPassword.Text);
command.ExecuteNonQuery();
conn.Close();

}







Tags:
evocampus
sql
visual studio
asp.net