Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
25
How to bind WebTextEdit control to Access table column on Web form
posted

I am new at Infragistics and have an MS Access background.  I want to bind a single WebTextEdit control on a Web form to a data column in an Access MDB table using an AccessdataSource.  I looked for  sample code/documentation and did not find anything.  Am new at this so I need a kind of beginner's type of assistance.  Any help is appreciated.

  • 25
    posted

    Tks.  Sample code was helpful.

  • 995
    Suggested Answer
    posted

    Hi,

    I assume, you want to bind single value from the Access database to the WebTextEdit control. You can use AccessDataSource to connect to the .mdb file and create connection string based on location of the Access database file. Using the “Configure Data Source” wizard, you can create SQL statement to retrieve data from the table.  When you have following simple Access table, you can use this code snippet to retrieve data from the location rowNumber X column “Name”  to bind to Text property of WebTextEdit. The rowNumber is hard coded.  

    String conn = this.AccessDataSource1.ConnectionString;

            OleDbConnection connec = new OleDbConnection(conn);

            try

                        {

                int rowNumber = 0; to get Sarah’ name

                connec.Open();

                OleDbDataReader dr;

                OleDbCommand cmd = new OleDbCommand("SELECT * FROM Table1", connec);

                dr = cmd.ExecuteReader();

                while (dr.Read() && rowNumber == 0)

                {

                    rowNumber++;

                    this.WebTextEdit1.Text = dr["Name"].ToString();

                }

                         }

                         catch (Exception)

                         {

                         }

    I have used following acces table:

    Table1

    ID

    Name

    City

    1

    Sarah

    Berlin

    2

    John

    London

    3

    Sam

    Paris