Results 1 to 2 of 2

Thread: Oledb

  1. #1
    Join Date
    Dec 1969

    Default Oledb

    Hi,<BR>I am connecting to MS-Access database where i want to retrieve more than one row. But using this code i am unable to retrieve row by row and column by column. Can anybody help me out with a sample code updated to this? Please give a sample code to retrieve 3 columns in 2 rows. Also i would like to use datareader. Can anybody place the datareader code in this?<BR><BR>===================================== ============================<BR>string connectionString = ConfigurationSettings.AppSettings.Get("strCon");<B R>OleDbConnection myConnection = new OleDbConnection( connectionString );<BR>string query = "select AccountBalance, SRate,APY, Ssection from savings where SSection=3";<BR>OleDbDataAdapter myAdapter = new OleDbDataAdapter( query, myConnection);<BR>OleDbDataReader myread=null;<BR>DataSet employeeData = new DataSet();<BR>myAdapter.Fill( employeeData );<BR>// Repeat for each table in the DataSet collection.<BR>foreach ( DataTable table in employeeData.Tables )<BR> {<BR>// Repeat for each row in the table.<BR>foreach ( DataRow row in table.Rows )<BR>{<BR> Label1.Text += row[0].ToString().Trim();<BR>}<BR> }<BR>}

  2. #2
    Join Date
    Dec 1969

    Default That last line of..

    .. code is the culprit. It&#039;s only taking the first field of each row and displaying it in Label1.<BR><BR>Why not use a datagrid and just bind the data table to it?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts