loading data from database to C#?

guys.. im trying to load data from access to the labels in C#..

but im having difficulty in doing that..

tnx for the urgent reply..


here are my codes..

da = new OleDbDataAdapter("Select * from partylist1",conn);

ds = new DataSet();


dataGridView1.DataSource = ds.Tables[0].DefaultView;

DataView dv = (DataView)dataGridView1.DataSource;

if (dv.Count > 0)


rbtnParty1.Text = dv[0]["partyname1"].ToString();

rbtnPres1.Text = dv[0]["president1"].ToString();

rbtnVice1.Text = dv[0]["vicepresident1"].ToString();


but it cant find the table where i stored the data

2 Answers

  • 1 decade ago
    Favorite Answer

    You need to look at your definition of your conn object. That's your connection object. It needs to point to the database (drive, path and filename)

  • Anonymous
    1 decade ago

    Use OleDbCommand to load data from Access database mdb

    using System;

    using System.Data;

    using System.Data.OleDb;

    class MainClass



    static void Main(string[] args)


    string ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\Northwind.mdb";

    string SQL = "SELECT * FROM Orders";

    OleDbConnection conn = new OleDbConnection(ConnectionString);

    OleDbCommand cmd = new OleDbCommand(SQL);

    cmd.Connection = conn;


    OleDbDataReader reader = cmd.ExecuteReader();

    while (reader.Read())


    Console.Write("OrderID:"+reader.GetInt32(0).ToString() );

    Console.Write(" ,");

    Console.WriteLine("Customer:" + reader.GetString(1).ToString() );






    The Output May Look Somewhat Like This

    OrderID:10330 ,Customer:LILAS

    OrderID:10331 ,Customer:BONAP

    OrderID:10332 ,Customer:MEREP

    OrderID:10333 ,Customer:WARTH

    OrderID:10334 ,Customer:VICTE



    For more information please checkout this url


Still have questions? Get your answers by asking now.