title: Databinding in WPF (C#)
body: <p>sorry for any inconveniece caused.</p>
  
  <p>Would like to ask about database or rather databinding</p>
  
  <p>My Window look like this: <a href="http://i25.tinypic.com/a0x5kn.jpg" rel="nofollow noreferrer">http://i25.tinypic.com/a0x5kn.jpg</a></p>
  
  <p>The browse button is look up the "My Network Place"</p>
  
  <pre><code>private void browseBtn_Click(object sender, RoutedEventArgs e)
   {
   FolderBrowserDialog dialog = new FolderBrowserDialog();
   Type t = dialog.GetType();
   System.Reflection.FieldInfo fi = t.GetField("rootFolder", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
   fi.SetValue(dialog, 0x0012); dialog.ShowDialog();
   dialog.ShowDialog();
   string selected = dialog.SelectedPath;
   computerText.Text = dialog.SelectedPath;
   }
  </code></pre>
  
  <p>So now my computerText.Text pass info, for eg: Computer1</p>
  
  <p>Now for the login, I want a database to see whether the info of the computerText is under which username and password. I have already created a database using Microsoft Access which look like this...</p>
  
  <pre><code>id computerName loginID password
  1  Computer1      com1    123456
  2  Computer2      com2    234567
  </code></pre>
  
  <p>So i roughly type the command for the loginBtn...</p>
  
  <pre><code>private void loginBtn_Click(object sender, RoutedEventArgs e)
  {
   // if the computerText.Text == my datasource's data [computerName] &amp;&amp; loginName.Text == my datasource's data [loginID] &amp;&amp; password.Text == my datasource's data [password]
   {
    loginStatus.Text = "Login Success!";
   }
   else
   {
    loginStatus.Text = "Login Failed!";
   }
  </code></pre>
  
  <p>So my question is:</p>
  
  <p>1) How to bind my database that I have now?</p>
  
  <p>2) how to code the above codes that I wanted to do?</p>
  
  <p>Help needed =[</p>
  
  <p><strong><em>Updated</em></strong>
  Have done the following code:</p>
  
  <pre><code>private void loginBtn_Click(object sender, RoutedEventArgs e)
  {
  OleDbConnection conn;
  OleDbCommand comm;
  OleDbDataReader dr;
  conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|/Database1.accdb");
  comm = new OleDbCommand("Select * from Remote where loginId =@id and password=@pass", conn); 
  comm.Parameters.Add(new OleDbParameter("@id",System.Data.oleDbType.NVarChar,20, "loginID")); 
  comm.Parameters.Add(new OleDbParameter("@pass",System.Data.oleDbType.NVarChar,20, "password"));
  conn.Open();
  dr = comm.ExecuteReader();
  conn.Close();
  
  if (dr.HasRows)
  {
  loginStatus.Text = "Login Successfully";
  }
  else
  {
  loginStatus.Text = "Login Failed!";
  string message = "Wrong username/password is been entered!";
  string caption = "Alert!";
  MessageBoxButton buttons = MessageBoxButton.OK;
  MessageBoxImage icon = MessageBoxImage.Warning;
  System.Windows.MessageBox.Show(message, caption, buttons, icon);
  }
  }
  </code></pre>
  
  <p>Prompt error: "The type or namespace name 'oleDbType' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)"</p>
  
  <p>And if i Remove the System.Data.oleDbType.NVarChar,20, it works perfectly fine, but when I type according to my database in my username and password, it prompt me Login Failed.. EG:</p>
  
  <pre><code>Computer Name : Computer1
  Username: com1
  Password: 123456
  </code></pre>