title: How to establish SQL Connection in Visual Studio using local mdf file
body: <p>I'm new to coding. I'm attempting to access a SQL Server file through WPF / C# and I am having trouble getting in the correct string, I believe. I do not yet fully understand SQL logins, but here is the code I have now, which I believe as close to correct as I can get on my own:</p>
  <pre><code>string CS = @&quot;Data Source=(LocalDB)\v11.0; Integrated Security=true; AttachDbFileName=C:\Users\Madison\source\repos\TheRealStudyBot\TheRealStudyBot\TestingData.mdf&quot;;
  
  SqlConnection con = new SqlConnection(CS);
  
  SqlCommand cmd = new SqlCommand(&quot;CREATE TABLE table1 (PK int, Name nvarchar(255), PRIMARY KEY *PK),);&quot;, con);
  
  con.Open();
  SqlDataReader rdr = cmd.ExecuteReader();
  con.Close();
  </code></pre>
  <p>This code is under <code>public MainWindow()</code>, after <code>InitializeComponent()</code>. The file path <em>should</em> be correct. The database is empty. I get this exception:</p>
  <blockquote>
  <p>Win32Exception: Unknown error (0x89c50118)</p>
  </blockquote>
  <p>Ran it once more and I think I may have accidentally altered my debug settings because now it also provides a window stating</p>
  <blockquote>
  <p>The solution does not contain the specified document</p>
  </blockquote>
  <p>(along with plenty of other jargony-code-exception-results-text). I don't see where I'm going wrong. Please help!</p>