title: How do I create a login page? My teacher did the registration and I'm trying to alter it after losing contact with him
body: <p>NOTE: I am using winforms C#
  This is the closest that I have come to getting it done. However, nothing seems to work? I'm using a SQL database with local storage... Any help is welcome. I know this is very late to release this question but I have got the rest of the project working.... hopefully. Im trying to make a Set List Generator for bands. But I need a global variable that holds the users ID number from the database if the passwords match. The project is dues sunday the 31st of July AEST.
  Thanks in advance</p>
  <p>Here is the code:</p>
  <pre><code>private static string GetConnectionString()
      {
          string dbPath = Directory.GetCurrentDirectory();
          string dbFileNameAndPath = dbPath + &quot;\\Details.mdf&quot;;
          string connectionString = string.Empty;
  
          //check if file exists (look in &quot;Directory&quot;)
          if (File.Exists(dbFileNameAndPath))
          {
              connectionString = &quot;Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=&quot; + dbFileNameAndPath + &quot;;Integrated Security=True;&quot;;
              return connectionString;
  
  
          }
          else
          {
              Console.Write(&quot;File not found&quot;);
              return connectionString;
          }
  
  
      }
  
      private void btn_login_Click(object sender, EventArgs e)
      {
          SqlConnection con = new SqlConnection();
          con.ConnectionString = GetConnectionString();
  
          string commandtxt = &quot;SELECT from AppUsers(Name, Password) where name = '&quot;+txt_username.Text+&quot;' AND password = '&quot;+txt_password.Text+&quot;' &quot;;
  
          SqlCommand sqlCommand = new SqlCommand(commandtxt, con);
  
          sqlCommand.CommandType = System.Data.CommandType.Text;
  
          string name = txt_username.Text;
          string password = txt_password.Text;
  
          sqlCommand.Parameters.Add(new SqlParameter(&quot;@Name&quot;, SqlDbType.NVarChar)).Value = name;
          sqlCommand.Parameters.Add(new SqlParameter(&quot;@Password&quot;, SqlDbType.NVarChar)).Value = password;
  
          con.Open();
          try
          {
              sqlCommand.ExecuteNonQuery();
          }
          catch (Exception)
          {
  
  
          }
          finally
          {
              con.Close();
          }
  
      }
  </code></pre>