Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hello,
I am developing a windows application with access database
and want to use crystal report for making reports.I am able to fetch data in data grid view by using BINDING SOURCE like this.
private void filter(string str)
{
string connectionstring = (@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Documents and Settings\nic-15\My Documents\ALRS.mdb");
OleDbConnection con = new OleDbConnection(connectionstring);//C:\Documents and Settings\nic-15\Desktop
con.Open();
OleDbDataAdapter da = new OleDbDataAdapter(str, con);
OleDbCommandBuilder cmdbuilder = new OleDbCommandBuilder(da);
DataTable dt = new DataTable();
dt.Locale = System.Globalization.CultureInfo.InvariantCulture;
da.Fill(dt);
bindingSourceViewRecord.DataSource = dt;
// dataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
dataGridView1.ReadOnly = true;
dataGridView1.DataSource = bindingSourceViewRecord;
}
private void buttonFilterSearch_Click(object sender, EventArgs e)
{

string str = "select thana,licence_number,sanction_date,renewal_date,licencee_name,father_name,village,type_of_arm,arms_number,valid_area from arms_records where thana='" + comboBoxThana.SelectedItem + "'";
filter(str);
}
This code works properly and so i found BindingSource very easy to use.Now i want to use this binding source to use in crystal report as datasource.
I am developing my first application
Please help.
thank you.
Posted
Updated 3-Dec-13 20:55pm
v2

1 solution

 
Share this answer
 
Comments
Member 10358986 9-Dec-13 2:46am    
Sir I couldn't solve my problem plz help.
Thomas ktg 9-Dec-13 3:10am    
What is the problem you have?
Member 10358986 9-Dec-13 4:05am    
Sir i want to make crystal reports after search query something like below.

CrystalReport1 myReport;
string connstring = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Documents and Settings\nic-15\My Documents\ALRS.mdb";
string query = "select thana,sanction_date,renewal_date,licencee_name,father_name from arms_records where thana='" + comboBoxThana.SelectedItem + "'";
OleDbConnection con = new OleDbConnection(connstring);
OleDbDataAdapter da = new OleDbDataAdapter(query, con);
DataSet ds = new DataSet();
da.Fill(ds, "Test");
myReport = new CrystalReport1();
myReport.SetDataSource(ds);
crystalReportViewer1.SelectionFormula = "{arms_records.thana}=" + comboBoxThana.SelectedItem;
crystalReportViewer1.ReportSource = myReport;
ds.Dispose();
con.Close();
But this code doesn't work.
Thomas ktg 9-Dec-13 4:18am    
You are not specific to your problem. Do you get any error? If so show the error you get.
Member 10358986 9-Dec-13 5:19am    
yes sir
when my page load there is data on the form now when i want to filter according to my query on button click it shows an error. that is
'A number currency boolean.............is expected here'

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900