开发者

Connecting Access file to Crystal Reports

开发者 https://www.devze.com 2023-03-18 04:09 出处:网络
I have an Access database file in my server and I need to connect it to Crystal Reports in my C# program.

I have an Access database file in my server and I need to connect it to Crystal Reports in my C# program.

I have succeeded in connecting to the database in my program but I don't know how to connect to Crystal 开发者_如何学JAVAReport.


Follow the following Code Snippet which will help you to connect to the Crystal Report from C# coding.

    CrystalReport1 myReport;    

    string connectionString = @"<Give your Connection String To Connect Access Database>(Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\4.accdb)";  
    string selectSQL = "<Provide the Query here to Retrieve Data>(Select ProductID,ProductName,ProductSpec From Products)";  

    OleDbConnection connection = new OleDbConnection(connectionString);  
    OleDbDataAdapter da = new OleDbDataAdapter(selectSQL, connection);  

    DataSet ds = new DataSet();  
    da.Fill(ds, "Test");  

    myReport = new CrystalReport1();  
    myReport.SetDataSource(ds);  
    myReportViewer1.ReportSource = myReport;  

    ds.Dispose();  
    connection.Close();     
0

精彩评论

暂无评论...
验证码 换一张
取 消