Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Updating .mdf table using Visual studio but when I quit its gone

$
0
0

Hello 

I am using 

  private void BtnUpdate_Click(object sender, EventArgs e)
        {

            try
            {
                SqlConnection con = new SqlConnection("Data Source=(LocalDB)\\v11.0;AttachDbFilename=|DataDirectory|\\Database1.mdf;Integrated Security=True;");
                con.Open();


                SqlCommand cmd1 = new SqlCommand("UPDATE Login SET Password='" + TxtNewPassword.Text + "'", con);
                cmd1.ExecuteNonQuery();

            }
            catch

            { }
       

There is only one row in database 

CREATE TABLE [dbo].[Login] (
    [Id]        INT          IDENTITY (1, 1) NOT NULL,
    [UserName]  VARCHAR (50) NULL,
    [Password]  VARCHAR (50) NULL,
       PRIMARY KEY CLUSTERED ([Id] ASC)
);

Before and After changing value i.e password I am able to login but after closing the windows form 
I check the database its not update and also cant login with the changed value 
so what should i do 
need help with that, I know I am doing a small mistake but dont know where need help 


Tahir Ayoub


Viewing all articles
Browse latest Browse all 31927

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>