Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7724173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:37:31+00:00 2026-06-01T04:37:31+00:00

Sir, I am having some problem regarding database in SQL Server. My project is

  • 0

Sir,
I am having some problem regarding database in SQL Server.
My project is desktop application with login method….
My program is written in C# executes normally as I want with no errors in my queries…
But data is not stored back to database which the program inserts or updates… My database is created by visual studio 2010 as a separate mdf file in data folder…
So kindly please help me in this. Here is a sample code :

private void btnLogin_Click(object sender, EventArgs e)
{
  try
  {
     using (SqlConnection cn = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\Database_File.mdf;Integrated Security=True;User Instance=True"))
     {
        using (SqlCommand cmd = new SqlCommand("select * from table_users where user_name='" + txtBoxUserName.Text + "' and user_password='" + txtBoxUserPass.Text + "' ",cn))
        {
          cn.Open();                        
          dr = cmd.ExecuteReader();
          while (dr.Read())
          {
            if (dr["user_name"].ToString() == txtBoxUserName.Text && dr["user_password"].ToString() == txtBoxUserPass.Text)
            {
              ...
              ...
              try
              {
                using (SqlCommand cmd1 = new SqlCommand("insert into table_user(id,user_name,user_status) values(" + key + "," + active_user_name + "',"+ user_status + ")",cn))
                {
                  cmd1.ExecuteNonQuery();
                  Thread form_name = new Thread(new ThreadStart(thread_Proc_form_name));
                  form_name.Start();
                }
              }
              catch  { throw;}
            }
          }
        }
     }
  }
  catch  { throw;}
}

The program runs as i want but when i look into the database table no changes are saved. For eg : when I login then no information of login is shown in the database on next run..
Same is the case for register… every time i run the app I have to register again and again. I don’t know where is the error. Please help me sir where i am going wrong….

Thanks & Regards
Saurabh Mahajan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T04:37:33+00:00Added an answer on June 1, 2026 at 4:37 am

    This snippet suggests to me that you’ve got a Database_File.mdf in your solution in Visual Studio:

    AttachDbFilename=|DataDirectory|\\Database_File.mdf 
    

    Each time you build your project, Database_File.mdf will be copied to the output directory, overwriting whatever file was there previously.

    This behaviour is by design.

    Note that user instances are deprecated, you should consider attaching your Database_File.mdf to your SQL Express instance for the duration of development or using something like SQL Server LocalDB.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having some trouble inserting an array into the sql database. my error
hello sir in login page i am validating username and password from server database.
Sir, I am developing an application in which i am to save some information
Hello Sir i want send list of data to php server i use following
Given a document written with normal quotes, e.g. Ben said buttons, dear sir. I
I'm having a problem updating a row after an inline edit. My ColModel is:
$(.menu-container).animate({top:25px}); $(.menu-container).animate({top:-900px}); $(.windows-container).animate({top:-730px}); hello sir.. i got a problem on queue in jquery.. what
sir i have got an error while running my project in ecclipse. The error
This is correct program and now running fine :) thank you sir I am
I am trying to create a simple simulation program of SIR-epidemics model in java.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.