Crystel Reports with Vs2010 C sharp

Jun 19 2014 4:27 AM
Hello Experts, 
I have connected or I am using this (please the code below ) code . With this code I want to connect with crystel reports get reports outupt on screen / print but how ??
 
 
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
using MySql.Data.MySqlClient;
namespace ConnectCsharpToMysql

{
class DBConnect
{
private MySqlConnection connection;
private string server;
private string database;
private string uid;
private string password;
private string woday;
//Constructor
public DBConnect()
{
Initialize();
}
//Initialize values
private void Initialize()
{ server = "localhost";
database = "bank";
uid = "myuid";
password = "mypwd";
string connectionString;
connectionString = "SERVER=" + server + ";" + "DATABASE=" + database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
connection = new MySqlConnection(connectionString);
}
//open connection to database
// private bool OpenConnection()
internal bool OpenConnection()
{
try
{
connection.Open();
string query = "SELECT * FROM mainautho ";
MySqlCommand cmd = new MySqlCommand(query, connection);
//Create a data reader and Execute the command
MySqlDataReader dataReader = cmd.ExecuteReader();
while (dataReader.Read())
{
woday = (dataReader["custname"] + "");
MessageBox.Show(woday);
}
//close Data Reader
dataReader.Close();
MessageBox.Show(woday);
return true;
//return true;
}
catch (MySqlException ex)
{
//When handling errors, you can your application's response based on the error number.
//The two most common error numbers when connecting are as follows:
//0: Cannot connect to server.
//1045: Invalid user name and/or password.
switch (ex.Number)
{
case 0:
MessageBox.Show("Cannot connect to server. Contact administrator");
break;
case 1045:
MessageBox.Show("Invalid username/password, please try again");
break;
}
return false;
}
}
//Close connection
internal bool CloseConnection()
{
try
{
connection.Close();
return true;
}
catch (MySqlException ex)
{
MessageBox.Show(ex.Message);
return false;
}
}
Thanks In Advance
Regards
anand