Return to Snippet

Revision: 27849
at June 25, 2010 04:40 by vedgiee


Initial Code
protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string connectionString = ConfigurationManager.ConnectionStrings["dragSlips_dbConnectionString"].ConnectionString;

            using (SqlConnection myConnection = new SqlConnection(connectionString))
            {
                SqlCommand login = new SqlCommand();
                login.Connection = myConnection;

                myConnection.Open();

                login.Parameters.AddWithValue("@username", txtUsername.Text);
                login.Parameters.AddWithValue("@password", txtPassword.Text);

                login.CommandText = "[login]";
                login.CommandType = System.Data.CommandType.StoredProcedure;

                object myResult = login.ExecuteScalar();

                if (Convert.ToInt32(myResult) == 0)
                {
                    lblLoggedIn.Text = "try again!";
                }
                else
                {
                    Response.Redirect("admin.aspx");
                }

                //MyConnection

                myConnection.Close();

            }
        }

Initial URL


Initial Description


Initial Title
Using Stored Procedure

Initial Tags


Initial Language
C#