How to use the same command(query) for different databases?

Stimulsoft Reports.NET discussion
Post Reply
alk
Posts: 8
Joined: Wed Dec 25, 2013 8:23 am

How to use the same command(query) for different databases?

Post by alk »

We got stuck with that peculiarity that the command is strictly bound to the database. Our application connects to Access database or to MS SQL Server directly. We developed report queries to satisfy both SQL dialects, so don't need two separate commands for two databases. Is there any way to have single generic command for both databases to bind to the relevant database in run-time?
theregister
Posts: 53
Joined: Wed Nov 27, 2013 5:24 pm

Re: How to use the same command(query) for different databas

Post by theregister »

I'm interested in this as well.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: How to use the same command(query) for different databas

Post by Alex K. »

Hello,

In this case you can get data from necessary database in your application and pass it in report as DataSet.

Thank you.
alk
Posts: 8
Joined: Wed Dec 25, 2013 8:23 am

Re: How to use the same command(query) for different databas

Post by alk »

Thank you for the reply.

Well, the question is how to use predefined columns then.
We designed the report and data filling based on some existing connection (say, StiOleDbSource over OleDb connection to an Access database). Evidently, we'd like to use the columns and their visual representation with the relevant data source in run-time, either for a new connection (MS SQL or Access) or DataSet, as you just specified.
How could we use the designed columns?

ps: I tried the approach with copying of columns as described in KB here - http://support.stimulsoft.com/index.php ... connection, but failed - no data is displayed in the report.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: How to use the same command(query) for different databas

Post by Alex K. »

Thank you.
alk wrote: but failed - no data is displayed in the report.
Can you please send us a sample project which reproduce the issue for analysis.

Thank you.
alk
Posts: 8
Joined: Wed Dec 25, 2013 8:23 am

Re: How to use the same command(query) for different databas

Post by alk »

Aleksey wrote: Can you please send us a sample project which reproduce the issue for analysis.
Thanks for the response.

Well, does it mean that the approach itself looks more-less correct from your point of view? You see, the original code is complex enough to be separated and shared with you in an easy way, so I'd try to dig a bit more by myself first. If I fail to find a solution I try to provide you with a sample project.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: How to use the same command(query) for different databas

Post by Alex K. »

Hello,

Yes, your way is correct. You can pass data as DataSet and also you can create a connection and datasources from code.
Please let us know if you need any additional help.

Thank you.
alk
Posts: 8
Joined: Wed Dec 25, 2013 8:23 am

Re: How to use the same command(query) for different databas

Post by alk »

Thank you for the help , I coped with the issue basing on the example I mentioned.

Unfortunately, the approach doesn't work for migrating relationships because of field names mismatch, but we suggest a workaround for this.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: How to use the same command(query) for different databas

Post by Alex K. »

Hello,

Ok.
Let us know if you need any additional help.

Thank you.
Post Reply