String connString = @"Provider=Microsoft.Jet.OLEDB.4.0;_
Data Source=..\\..\\myDB.mdb;User ID=Admin;Password=";
OleDbConnection conn = new OleDbConnection(connString);
conn.Open();
string query = "SELECT studentID, firstName, lastName, birthDate, _
address, contactNo FROM studentInfo";
OleDbDataAdapter oleDA = new OleDbDataAdapter(query,conn);
// code to get data from the DB
DBConnection DBConn = new DBConnection();
OleDbDataAdapter myDataAdapter = DBConn.getDataFromDB();
// use the created Dataset to fill it with data got
// from the DB by using the DataAdapter
DataSet dataReport = new DataSet();
myDataAdapter.Fill(dataReport,"myPersonalInfoTable");
// create a new report from the created CrystalReport
myDataReport myDataReport = new myDataReport();
// set the data source of the report
myDataReport.SetDataSource(dataReport);
// set the report source of the created “crystalReportViewer”
// component to the created report
crystalReportViewer1.ReportSource = myDataReport;
Tag : .NET, Win (Windows App), LINQ, C#, VS 2010 (.NET 4.x), Windows