title: Connecting asp.net with MS access 2007 in VS 2010
body: <p>I have created a small table of student info in MS Access 2007. The table name is "stdinfo" and fields are rollno,sname,sfather,address.
  Now i want to display the table fields in asp.net application.</p>
  
  <p>code behind code is </p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
          {
              string ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:|Users|mac|Desktop|db.accdb;";
              OleDbConnection cn = new OleDbConnection(ConnectionString);
              OleDbCommand cmd = new OleDbCommand();
              cmd.CommandText = "Select * from stdinfo";
              cmd.Connection = cn;
              cn.Open();
              rolllbl.Text = Convert.ToString(cmd.ExecuteNonQuery());
              cn.Close();
          }
  </code></pre>
  
  <p>and aspx code is </p>
  
  <pre><code>&lt;p&gt;
          &lt;asp:Label ID="rolllbl" runat="server" Text="RollNo."&gt;&lt;/asp:Label&gt;
  &amp;nbsp;&amp;nbsp;&amp;nbsp;
      &lt;/p&gt;
      &lt;p&gt;
          &amp;nbsp;&lt;asp:Label ID="namelbl" runat="server" Text="Name"&gt;&lt;/asp:Label&gt;
  &amp;nbsp;&lt;/p&gt;
      &lt;p&gt;
          &lt;asp:Label ID="fnamelbl" runat="server" Text="Fname"&gt;&lt;/asp:Label&gt;
  &amp;nbsp;&amp;nbsp;&amp;nbsp;
      &lt;/p&gt;
      &lt;p&gt;
          &lt;asp:Label ID="addlbl" runat="server" Text="Address"&gt;&lt;/asp:Label&gt;
      &lt;/p&gt;
  </code></pre>
  
  <p>I did not wish to write the connection string in web config file. I am using VS 2010.</p>
  
  <p>Is there any thing i need to add in the code behind ? the code is not working...</p>