abdul hafeez

abdul hafeez

  • NA
  • 2
  • 542

connection issue

Oct 11 2022 10:19 AM

i have this code 

 

but the data is not save in my local database please help me.

(

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication2
{
   
   
        enum Insert_DATA{string Email, string Password, string Repeat_Password}
        {

            //String s = "Data Source=HAFEEZ-PMO;Initial Catalog=PPG_Biller;Integrated Security=true;providerName=System.Data.SqlClient";

            string s = "Server=HAFEEZ-PMO;Database=AHBKS;User ID=hafeez;Password=sa123;Trusted_Connection=False;";
            using (SqlConnection connection = new SqlConnection(hafeez))
            {
                try
                {
                    connection.Open();
                    SqlCommand cmd = new SqlCommand();
                    cmd.Connection = connection;
                    cmd.CommandText = "SP_INSERT_DATA";
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@Email", Email);
                    cmd.Parameters.AddWithValue("@Password", Password);
                    cmd.Parameters.AddWithValue("@Repeat_Password", Repeat_Password);
                    cmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (connection.State == ConnectionState.Open)
                        connection.Close();
                }
           
        

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Insert_Data("12345", "12345", 1);
        }
    }
}

)


Answers (2)