locked
AccessDataSource (Access DB) cotrolled via textbox RRS feed

  • Question

  • User-584964728 posted

    hi, I'm a new on ASP.net and I have a couple problems

    1- how to make a search (textbox) for the AccessDataSource (Access DB connectivity) for a specific field,

    2- and how to put the found record in another textbox (withou using gridview, or listview and the other), all what I want to say that I want to fix a textbox control and connecting it to a specific field from the Access DB.

    Thursday, May 26, 2011 11:54 AM

Answers

  • User3866881 posted

    Hello:)

    To your first question——

    You should set a unknown parameter variable in your select sql statament for your Access's db and use ControlParameter to bind its value to the parameter. Something like what I've shown to you in this similar sample (though it's type of SqlDataSource, but the wizard steps are nearly the same. You can change them to AccessDataSource and apply it)

    http://www.exforsys.com/tutorials/asp.net-2.0/asp.net-2.0-gridview-filtering.html

    To your 2nd question——

    Just use OleDBConnection+OleDbCommand——

    using (OleDbConnection con = new OleDbConnection(……))

    {

      using (OleDbCommand cmd = new OleDbCommand("select top 1 fieldname from xxx where ……",con))

       {

             con.Open();

             TextBox1.Text = cmd.ExecuteScalar().ToString();

       }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, May 28, 2011 9:49 PM