Showing posts with label app. Show all posts
Showing posts with label app. Show all posts

Monday, March 26, 2012

Dynamic Query

Hi!

I am trying to dynamically modify my pass-through query containing a
procedure call with 2 parameters.

When I run my access app, I get this error: "Object or provider is not
capable of performing reuqested operation."

Below is my access code:

Dim varItem As Variant
Dim strSQL As String
Dim cat As ADOX.Catalog
Dim cmd As ADODB.Command
Dim strMyDate As String, dtMyDate As Date

dtMyDate = CDate([Forms]![ySalesHistory]![Start Date])
strMyDate = Format(dtMyDate, "yyyymmdd")

strSQL = "procCustomerSalesandPayments '" & strMyDate & "', '" &
[Forms]![ySalesHistory]![Customer Number] & "'"

Set cat = New ADOX.Catalog
Set cat.ActiveConnection = CurrentProject.Connection

'= = >NOTE: THIS IS WHERE THE ERROR POPS OUT!
Set cmd = cat.Procedures("Ben_CustomerSalesandPayments").Command

cmd.CommandText = strSQL
Set cat.Procedures("Ben_CustomerSalesandPayments").Command = cmd

DoCmd.OpenReport stDocName, acViewPreview

Set cat = Nothing
Set cmd = Nothing

Can anyone help me out?

Thanks.Ben (pillars4@.sbcglobal.net) writes:

Quote:

Originally Posted by

I am trying to dynamically modify my pass-through query containing a
procedure call with 2 parameters.
>
When I run my access app, I get this error: "Object or provider is not
capable of performing reuqested operation."


ADOX is nothing I have experience of, but I found in MSDN under the Command
property in ADOX that it says:

An error will occur when getting and setting this property if the
provider does not support persisting commands.

Which provider are you using? How does your connection string look like?

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Below is the connection string:

ODBC;DSN=YES2;DATABASE=YES100SQLC;

"Erland Sommarskog" <esquel@.sommarskog.sewrote in message
news:Xns99621E8AFE47Yazorman@.127.0.0.1...

Quote:

Originally Posted by

Ben (pillars4@.sbcglobal.net) writes:

Quote:

Originally Posted by

>I am trying to dynamically modify my pass-through query containing a
>procedure call with 2 parameters.
>>
>When I run my access app, I get this error: "Object or provider is not
>capable of performing reuqested operation."


>
ADOX is nothing I have experience of, but I found in MSDN under the
Command
property in ADOX that it says:
>
An error will occur when getting and setting this property if the
provider does not support persisting commands.
>
Which provider are you using? How does your connection string look like?
>
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
>
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

|||Ben (pillars4@.sbcglobal.net) writes:

Quote:

Originally Posted by

Below is the connection string:
>
ODBC;DSN=YES2;DATABASE=YES100SQLC;


And what is in that DSN?

Particular which OLE DB provider do you use? I had a look in a book on
ADO, and it said that the only two providers to support ADOX are the
Jet provider and SQLOLEDB. The book is a bit old, but if ODBC means that
you are using MSDASQL, then we have the answer to your problem. Change
to use SQLOLEDB instead.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

dynamic procedure creation - possible?

Hi Gurus
I am trying to develop an application around SQL server. The app allows
the user to input a where clause at runtime, which the application runs
against. The only way the app can use the input where clause is by
building an SQL statement including the where clause, and then calling
sp_executeSQL against it. This is inefficient; ideally I would like to
compile the SQL statement (as it will be used multiple times) - but how
can I do this? I cannot call CREATE PROCEDURE, as that cannot be done
from inside another statement (it must be done explicitly with a
hardcoded where statement).
Is there any wat I can improve on building the statement and calling
sp_executeSQL every time I need to run it?"neilsolent" <neil@.solenttechnology.co.uk> wrote in message
news:1169494423.824216.35130@.38g2000cwa.googlegroups.com...
> Hi Gurus
> I am trying to develop an application around SQL server. The app allows
> the user to input a where clause at runtime, which the application runs
> against. The only way the app can use the input where clause is by
> building an SQL statement including the where clause, and then calling
> sp_executeSQL against it. This is inefficient;
Why do you think that? SQL Server will cache and reuse SQL queries sent
using sp_executesql, especially if you use parameter markers in the query.
See
Batch Compilation, Recompilation, and Plan Caching Issues in SQL Server 2005
http://www.microsoft.com/technet/pr...005/recomp.mspx
Execution Plan Caching and Reuse
http://msdn2.microsoft.com/en-us/library/aa175244(SQL.80).aspx

> ideally I would like to
> compile the SQL statement (as it will be used multiple times) - but how
> can I do this? I cannot call CREATE PROCEDURE, as that cannot be done
> from inside another statement (it must be done explicitly with a
> hardcoded where statement).
> Is there any wat I can improve on building the statement and calling
> sp_executeSQL every time I need to run it?
>
No. That is really a perfectly fine thing to do. Consider using parameter
markers in sp_executesql to get query plan reuse and reduce compilations.
However if the volume of these dynamic queries is not great, or the cost of
each query to execute is large, then plan reuse may not be important or even
desirable.
David|||Thanks very much for that David.
The queries don't have parameters - they are always exactly the same
every time they are run (the user may change the where clause, but this
will be a very infrequent event). However, there could be up to 255 of
these queries (and where clauses), which could potentially all get
called (in series) every time a row is inserted into a certain key
table. A row is inserted in the key table possibly several times a
second (worst case).|||"neilsolent" <neil@.solenttechnology.co.uk> wrote in message
news:1169495992.357049.50780@.m58g2000cwm.googlegroups.com...
> Thanks very much for that David.
> The queries don't have parameters - they are always exactly the same
> every time they are run (the user may change the where clause, but this
> will be a very infrequent event). However, there could be up to 255 of
> these queries (and where clauses), which could potentially all get
> called (in series) every time a row is inserted into a certain key
> table. A row is inserted in the key table possibly several times a
> second (worst case).
>
Ok, 255 different queries isn't much at all. I would just let SQL Server
cache them.
David

dynamic procedure creation - possible?

Hi Gurus
I am trying to develop an application around SQL server. The app allows
the user to input a where clause at runtime, which the application runs
against. The only way the app can use the input where clause is by
building an SQL statement including the where clause, and then calling
sp_executeSQL against it. This is inefficient; ideally I would like to
compile the SQL statement (as it will be used multiple times) - but how
can I do this? I cannot call CREATE PROCEDURE, as that cannot be done
from inside another statement (it must be done explicitly with a
hardcoded where statement).
Is there any wat I can improve on building the statement and calling
sp_executeSQL every time I need to run it?
"neilsolent" <neil@.solenttechnology.co.uk> wrote in message
news:1169494423.824216.35130@.38g2000cwa.googlegrou ps.com...
> Hi Gurus
> I am trying to develop an application around SQL server. The app allows
> the user to input a where clause at runtime, which the application runs
> against. The only way the app can use the input where clause is by
> building an SQL statement including the where clause, and then calling
> sp_executeSQL against it. This is inefficient;
Why do you think that? SQL Server will cache and reuse SQL queries sent
using sp_executesql, especially if you use parameter markers in the query.
See
Batch Compilation, Recompilation, and Plan Caching Issues in SQL Server 2005
http://www.microsoft.com/technet/prodtechnol/sql/2005/recomp.mspx
Execution Plan Caching and Reuse
http://msdn2.microsoft.com/en-us/library/aa175244(SQL.80).aspx

> ideally I would like to
> compile the SQL statement (as it will be used multiple times) - but how
> can I do this? I cannot call CREATE PROCEDURE, as that cannot be done
> from inside another statement (it must be done explicitly with a
> hardcoded where statement).
> Is there any wat I can improve on building the statement and calling
> sp_executeSQL every time I need to run it?
>
No. That is really a perfectly fine thing to do. Consider using parameter
markers in sp_executesql to get query plan reuse and reduce compilations.
However if the volume of these dynamic queries is not great, or the cost of
each query to execute is large, then plan reuse may not be important or even
desirable.
David
|||Thanks very much for that David.
The queries don't have parameters - they are always exactly the same
every time they are run (the user may change the where clause, but this
will be a very infrequent event). However, there could be up to 255 of
these queries (and where clauses), which could potentially all get
called (in series) every time a row is inserted into a certain key
table. A row is inserted in the key table possibly several times a
second (worst case).
|||"neilsolent" <neil@.solenttechnology.co.uk> wrote in message
news:1169495992.357049.50780@.m58g2000cwm.googlegro ups.com...
> Thanks very much for that David.
> The queries don't have parameters - they are always exactly the same
> every time they are run (the user may change the where clause, but this
> will be a very infrequent event). However, there could be up to 255 of
> these queries (and where clauses), which could potentially all get
> called (in series) every time a row is inserted into a certain key
> table. A row is inserted in the key table possibly several times a
> second (worst case).
>
Ok, 255 different queries isn't much at all. I would just let SQL Server
cache them.
David
sql

dynamic procedure creation - possible?

Hi Gurus
I am trying to develop an application around SQL server. The app allows
the user to input a where clause at runtime, which the application runs
against. The only way the app can use the input where clause is by
building an SQL statement including the where clause, and then calling
sp_executeSQL against it. This is inefficient; ideally I would like to
compile the SQL statement (as it will be used multiple times) - but how
can I do this? I cannot call CREATE PROCEDURE, as that cannot be done
from inside another statement (it must be done explicitly with a
hardcoded where statement).
Is there any wat I can improve on building the statement and calling
sp_executeSQL every time I need to run it?"neilsolent" <neil@.solenttechnology.co.uk> wrote in message
news:1169494423.824216.35130@.38g2000cwa.googlegroups.com...
> Hi Gurus
> I am trying to develop an application around SQL server. The app allows
> the user to input a where clause at runtime, which the application runs
> against. The only way the app can use the input where clause is by
> building an SQL statement including the where clause, and then calling
> sp_executeSQL against it. This is inefficient;
Why do you think that? SQL Server will cache and reuse SQL queries sent
using sp_executesql, especially if you use parameter markers in the query.
See
Batch Compilation, Recompilation, and Plan Caching Issues in SQL Server 2005
http://www.microsoft.com/technet/prodtechnol/sql/2005/recomp.mspx
Execution Plan Caching and Reuse
http://msdn2.microsoft.com/en-us/library/aa175244(SQL.80).aspx
> ideally I would like to
> compile the SQL statement (as it will be used multiple times) - but how
> can I do this? I cannot call CREATE PROCEDURE, as that cannot be done
> from inside another statement (it must be done explicitly with a
> hardcoded where statement).
> Is there any wat I can improve on building the statement and calling
> sp_executeSQL every time I need to run it?
>
No. That is really a perfectly fine thing to do. Consider using parameter
markers in sp_executesql to get query plan reuse and reduce compilations.
However if the volume of these dynamic queries is not great, or the cost of
each query to execute is large, then plan reuse may not be important or even
desirable.
David|||Thanks very much for that David.
The queries don't have parameters - they are always exactly the same
every time they are run (the user may change the where clause, but this
will be a very infrequent event). However, there could be up to 255 of
these queries (and where clauses), which could potentially all get
called (in series) every time a row is inserted into a certain key
table. A row is inserted in the key table possibly several times a
second (worst case).|||"neilsolent" <neil@.solenttechnology.co.uk> wrote in message
news:1169495992.357049.50780@.m58g2000cwm.googlegroups.com...
> Thanks very much for that David.
> The queries don't have parameters - they are always exactly the same
> every time they are run (the user may change the where clause, but this
> will be a very infrequent event). However, there could be up to 255 of
> these queries (and where clauses), which could potentially all get
> called (in series) every time a row is inserted into a certain key
> table. A row is inserted in the key table possibly several times a
> second (worst case).
>
Ok, 255 different queries isn't much at all. I would just let SQL Server
cache them.
David

Friday, March 9, 2012

Dynamic Dynamic Filters

Hello,
I am attempting to use dynamic filters on merge replication to filter rows. In my front end app I am using the ActiveX Merge object to set the Host_Name property. My question is: Is it possible to set the host name to a more complex string?
example:
.HostName = "Col = 'Val1' OR (Col = 'Val2' AND Col = 'Val3')"
The problem I am running into is that the sql wizard for creating the dynamic filters runs a check on the sql statement and won't allow something like:
SELECT <published_columns> FROM [dbo].[Table1] WHERE Host_Name()
Technically if I could somehow bypass the wizard to enter the filter rules this should work. Anyone know if this is possible? Or possibly another way to work around this so that you can pass more than 1 value to the where clause? I suppose you could do so
mething like:
SELECT <published_columns> FROM [dbo].[Table1] WHERE Col = Host_Name()
HostName = "'Val1' OR (Col = 'Val2' AND Col = 'Val3')"
Would this be the only way? Any feedback would be greatly appreciated. Thanks in advance.
I'm unsure on what your filtering condition is. For instance your filter
should evaluate to a boolean true or false. Yours evaluates to hostname.
You can use a UDF to extend the functionalty of your filter or you can do
stuff like this
SELECT <published_columns> FROM [dbo].[authors] WHERE host_name() like 'p%'
or use a subquery
SELECT <published_columns> FROM [dbo].[authors] WHERE host_name() in (select
Servername from ServerList where state='ca')
Hilary Cotter
Looking for a book on SQL Server replication?
http://www.nwsu.com/0974973602.html
"Steve" <Steve@.discussions.microsoft.com> wrote in message
news:D7626D05-A0A6-4F19-963D-8B588A20AC6E@.microsoft.com...
> Hello,
> I am attempting to use dynamic filters on merge replication to filter
rows. In my front end app I am using the ActiveX Merge object to set the
Host_Name property. My question is: Is it possible to set the host name to a
more complex string?
> example:
> .HostName = "Col = 'Val1' OR (Col = 'Val2' AND Col = 'Val3')"
> The problem I am running into is that the sql wizard for creating the
dynamic filters runs a check on the sql statement and won't allow something
like:
> SELECT <published_columns> FROM [dbo].[Table1] WHERE Host_Name()
> Technically if I could somehow bypass the wizard to enter the filter rules
this should work. Anyone know if this is possible? Or possibly another way
to work around this so that you can pass more than 1 value to the where
clause? I suppose you could do something like:
> SELECT <published_columns> FROM [dbo].[Table1] WHERE Col = Host_Name()
> HostName = "'Val1' OR (Col = 'Val2' AND Col = 'Val3')"
> Would this be the only way? Any feedback would be greatly appreciated.
Thanks in advance.
>
>
|||Yes mine purposely evaluates to hostname. What I am trying to do is set the filter to:
SELECT <published_columns> FROM [dbo].[Table1] WHERE Host_Name()
and then set hostname to something like:
Col = 'Val1' OR Col = 'Val2'
So that the resulting select will look like:
SELECT <published_columns> FROM [dbo].[Table1] WHERE Col = 'Val1' OR Col = 'Val2'
Or whatever other complex WHERE clause that I choose. The problem is that it won't except the above filter. My work around listed above should work (I have yet to test it). Although I am interested in other possibilites to achieve the same results. This s
eems fairly basic unless I am missing something?
"Hilary Cotter" wrote:

> I'm unsure on what your filtering condition is. For instance your filter
> should evaluate to a boolean true or false. Yours evaluates to hostname.
> You can use a UDF to extend the functionalty of your filter or you can do
> stuff like this
> SELECT <published_columns> FROM [dbo].[authors] WHERE host_name() like 'p%'
> or use a subquery
> SELECT <published_columns> FROM [dbo].[authors] WHERE host_name() in (select
> Servername from ServerList where state='ca')
>
> --
> Hilary Cotter
> Looking for a book on SQL Server replication?
> http://www.nwsu.com/0974973602.html
>
> "Steve" <Steve@.discussions.microsoft.com> wrote in message
> news:D7626D05-A0A6-4F19-963D-8B588A20AC6E@.microsoft.com...
> rows. In my front end app I am using the ActiveX Merge object to set the
> Host_Name property. My question is: Is it possible to set the host name to a
> more complex string?
> dynamic filters runs a check on the sql statement and won't allow something
> like:
> this should work. Anyone know if this is possible? Or possibly another way
> to work around this so that you can pass more than 1 value to the where
> clause? I suppose you could do something like:
> Thanks in advance.
>
>
|||Steve,
you could have a mapping table which relates values (Val1 and Val2) to
hostnames. In your example there would be 2 rows:
-- MAPPINGTABLE --
hostname1 val1
hostname1 val2
If you include this table in the filter, you can achieve the clause you want
to create.
HTH,
Paul Ibison
|||Paul,
I am not familiar with mapping tables and I have been unable to find any information relating to them. Could you provide an example of what you mean or possibly a link to some information? Thanks.
|||Steve,
it's easiest if I explain how I set up a test: I had 2 tables - region and
HostnameLookup - shown below. The HostnameLookup table defines the multiple
values I'm interested in. I use dynamic filters to filter the HostnameLookup
table using HOST_NAME() and a join filter to join to the region table.
Editing the 2nd step on the merge agent's job to include: -Hostname
PaulsComputer means that only 2 regions get replicated. I've listed the
exact text below in case you want to recreate it to test.
HTH,
Paul Ibison
Region
RegionID RegionDescription rowguid
-- -- --
1 Eastern 9A6377F0-70DF-4A5C-962D-B41A41EFA82B
2 Western C0CAEFAD-7B8C-43D6-87ED-920494A5C60C
3 Northern 6CD9AA33-BE2D-4DCF-B447-745A3B86818E
4 Southern B4826E41-96D6-457C-8645-DD4984AE3BF5
HostnameLookup
RegionDescription Hostname rowguid
-- -- --
Northern PaulsComputer 2367C78A-1001-417B-A3B1-1C74B23F8131
Southern PaulsComputer 4F563C4D-8479-4A7D-A938-490DD514F12A
Filter Clause for HostnameLookup:
SELECT <published_columns> FROM [dbo].[HostnameLookup]
WHERE HostnameLookup.Hostname = HOST_NAME()
Filter Clause for Region:
< All rows published >
Join Filter:
Filtered table is HostnameLookup
Table to FIlter is Region
SELECT <published_columns> FROM [dbo].[HostnameLookup]
INNER JOIN [dbo].[Region] ON Hostnamelookup.regiondescription =
region.regiondescription
Edit the 2nd step on the merge agent's job to include: -Hostname
PaulsComputer
Run the snapshot then merge agents and only 2 regions should be replicated.
|||Hi Paul,
I saw your suggested solution in another web page
http://www.replicationanswers.com/Merge.asp
I was wondering if this Host_Name() is a function that will return the
computer name of the device/desktop that the subscriber database is residing
on?
If I am using mobile devices as subscribers and they have a web service
method called Reader_Id() which returns the unique id of the mobile device,
can I modify your solution accordingly?
Thank you.
"Paul Ibison" wrote:

> Steve,
> it's easiest if I explain how I set up a test: I had 2 tables - region and
> HostnameLookup - shown below. The HostnameLookup table defines the multiple
> values I'm interested in. I use dynamic filters to filter the HostnameLookup
> table using HOST_NAME() and a join filter to join to the region table.
> Editing the 2nd step on the merge agent's job to include: -Hostname
> PaulsComputer means that only 2 regions get replicated. I've listed the
> exact text below in case you want to recreate it to test.
> HTH,
> Paul Ibison
> Region
> --
> RegionID RegionDescription rowguid
> -- -- --
> 1 Eastern 9A6377F0-70DF-4A5C-962D-B41A41EFA82B
> 2 Western C0CAEFAD-7B8C-43D6-87ED-920494A5C60C
> 3 Northern 6CD9AA33-BE2D-4DCF-B447-745A3B86818E
> 4 Southern B4826E41-96D6-457C-8645-DD4984AE3BF5
> HostnameLookup
> --
> RegionDescription Hostname rowguid
> -- -- --
> Northern PaulsComputer 2367C78A-1001-417B-A3B1-1C74B23F8131
> Southern PaulsComputer 4F563C4D-8479-4A7D-A938-490DD514F12A
>
> Filter Clause for HostnameLookup:
> SELECT <published_columns> FROM [dbo].[HostnameLookup]
> WHERE HostnameLookup.Hostname = HOST_NAME()
> Filter Clause for Region:
> < All rows published >
> Join Filter:
> Filtered table is HostnameLookup
> Table to FIlter is Region
> SELECT <published_columns> FROM [dbo].[HostnameLookup]
> INNER JOIN [dbo].[Region] ON Hostnamelookup.regiondescription =
> region.regiondescription
> Edit the 2nd step on the merge agent's job to include: -Hostname
> PaulsComputer
> Run the snapshot then merge agents and only 2 regions should be replicated.
>
>

Wednesday, March 7, 2012

Dynamic data source name...

Sorry if this is a pretty basic question.. but my team here is working on SQL Reporting app for the first time.

is it possible to put the data source name/connection string in a config file (like web.config) and have the reports use that from there? What is the standard way of doing this while trying to deploy the reports on different servers?

Thanks

Various approaches for dynamic database connections in RS 2000 are available:
* Use a custom data processing extension
http://msdn.microsoft.com/library/en-us/RSPROG/htm/rsp_prog_extend_dataproc_5c2q.asp
* Use the SOAP API by calling SetDataSourceContents:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rsprog/htm/rsp_ref_soapapi_service_lz_2ojd.asp
* Use the linked server functionality of SQL Server; please check this thread:
http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.sqlserver.reportingsvcs&mid=848bac6b-98a2-4de7-abfd-bf199a99b660&sloc=en-us
* If the databases are on the same server, use a dynamic query text (i.e. ="select * from " & Parameters!DatabaseName.Value & "..table")
* If you're just toggling between two or three databases, you can publish the same report 3 times with 3 different names using 3 different data sources and write a main report that shows/hides the correct subreport based on whatever criteria you want.

In addition, native support (expression-based connection strings) is available in RS 2005: Finish the design of the datasets with a constant connection string and make sure everything works. Then, go back to the data tab and open the dataset/data source dialog and change the connection string to be an expression. Use string concatenation to plug in the parameter value. Here is an example of how the RDL would look for a parameter-based connection string:
<DataSources>
<DataSource Name="Northwind">
<ConnectionProperties>
<DataProvider>SQL</DataProvider>
<ConnectString>="data source=" &amp; Parameters!ServerName.Value &amp; ";initial catalog=Northwind;"</ConnectString>
<IntegratedSecurity>true</IntegratedSecurity>
</ConnectionProperties>
</DataSource>
</DataSources>

<ReportParameters>
<ReportParameter Name="ServerName">
<DataType>String</DataType>
<Prompt>ServerName</Prompt>
</ReportParameter>
</ReportParameters>


You can also check this blog posting: http://blogs.msdn.com/bwelcker/archive/2005/04/29/413343.aspx

-- Robert

|||I can't get the 2005 solution for data source expressions to work if I need to use the stored proc command type. Keeps getting reset to text. Is this a bug?|||

Staceyd,

We ran into the same problem with RS 2005 when trying to use a DynamicSource with a stored procedure with the query type reverting to text.

We ended up just copying the stored procedure as the text based query . This of course means that every report that would normally based off of one stored procedure has to be individually modified if we need to add or subtract fields.

Yes we ended up with our Dynamic connection string, but we also added to our maintenance headache.

Build your report with the stored procedure as its dataset, make sure it runs the way you want it to, then:

1. Create a report parameter "ConnectionString", make sure that this parameter is listed at the top of the parameter list. <example: two existing parameters BeginDate and EndDate, when you add ConnectionString Parameter, move it to the top of the list>

2. If you are planning to have interactivity with another report either via graphs or navigation, create a calculated field in the data set called ConnectionString and make its expression value the ConnectionString Parameter. Use this field to pass the connection string to your external navigation link.

3. Create a new datasource called DynamicSource, for its connection string use the paramter you created earlier (=Parameters!ConnectionString.value). For the query string you have to paste in sql of your stored procedure.

4. Test the report.

If anyone finds another work around where the link to the actual stored procedure can be maintained without it reverting back to text based query, please speak up:)

|||

RS_Trans

thanks for the quick reply! And yes, if anyone has a method to do this without reverting back to text based query it would be appreciated, until then I will use that solution

|||Does it works?|||

OK. found it..

The data source must be report specific data source.

Regards,

Visu

|||

Hi,
I am new to Reporting Services. While browsing through the forums, I came across this posting.

Well I just wanted to know whether the above given solution works or not.

Please let me know.

Regards,
Sudhakara.T.P.

|||

This seems to work for SQL datasources....but what about XML datasources. I have a situation where I am getting data from a website that has data criteria in the request string (unfortunately, this is not exactly a webservice). So, I need to dynamically format the request string that is the ConnectString of the XML datasource.

Any thoughts?

|||

I tried the solution with a report specific data source and parametrizinf the connection string. I get the follwing error

'An error occured duing report processing.

Cannot connect to the data source.'

I checked the data base and the server name are correct.

Any pointers please?

|||

Can any one please explain more on the solution for dynamic data source connectivity in reporting services 2000

* Use the SOAP API by calling SetDataSourceContents?

If any one has implemented it, can you please provide a step wise pointer to how to get this done.

Will be of great help!

|||

Hi Friend

Did you able to get further information on SOAP API by calling SetDataSourceContents ? if yes please pass it to me

It would be really nice to have this info..

|||

Hi,

Can't seem to get the dynamic data source name to work either, yet we have a brand new SQL Server 2005 installation running with Reporting Services.

When I simply go to the Data tab to add the ="....." to my existing connection string (so I'm not even trying to use any report parameter at this stage), it still doesn't work as if it wouldn't interpret it correctly... could someone help? Is there a switch somewhere to trigger the data source expression in RS 2005?

Thanks in advance,

Xavier

PS: We run a french version...

|||

Ok, found the problem, for those of you who run into the same problem, (ie : '[BC32017] Comma, ')', or a valid expression continuation expected.'.), you might want to make sure there's no space in your Data Source Name, that was the problem for me...

Good luck!

Xavier

|||Hi,

I would suggest you to go ahead create a datasource through ReportManager.
By this way you can make the Reports more flexible and scalable.
I did it in the same way and it did work out well as it was more flexible.
Do not forget to make the datasource shared one.

Regards,
Vamsi Krishna Korasiga.

Dynamic data source name...

Sorry if this is a pretty basic question.. but my team here is working on SQL Reporting app for the first time.

is it possible to put the data source name/connection string in a config file (like web.config) and have the reports use that from there? What is the standard way of doing this while trying to deploy the reports on different servers?

Thanks

Various approaches for dynamic database connections in RS 2000 are available:
* Use a custom data processing extension
http://msdn.microsoft.com/library/en-us/RSPROG/htm/rsp_prog_extend_dataproc_5c2q.asp
* Use the SOAP API by calling SetDataSourceContents:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rsprog/htm/rsp_ref_soapapi_service_lz_2ojd.asp
* Use the linked server functionality of SQL Server; please check this thread:
http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.sqlserver.reportingsvcs&mid=848bac6b-98a2-4de7-abfd-bf199a99b660&sloc=en-us
* If the databases are on the same server, use a dynamic query text (i.e. ="select * from " & Parameters!DatabaseName.Value & "..table")
* If you're just toggling between two or three databases, you can publish the same report 3 times with 3 different names using 3 different data sources and write a main report that shows/hides the correct subreport based on whatever criteria you want.

In addition, native support (expression-based connection strings) is available in RS 2005: Finish the design of the datasets with a constant connection string and make sure everything works. Then, go back to the data tab and open the dataset/data source dialog and change the connection string to be an expression. Use string concatenation to plug in the parameter value. Here is an example of how the RDL would look for a parameter-based connection string:
<DataSources>
<DataSource Name="Northwind">
<ConnectionProperties>
<DataProvider>SQL</DataProvider>
<ConnectString>="data source=" &amp; Parameters!ServerName.Value &amp; ";initial catalog=Northwind;"</ConnectString>
<IntegratedSecurity>true</IntegratedSecurity>
</ConnectionProperties>
</DataSource>
</DataSources>

<ReportParameters>
<ReportParameter Name="ServerName">
<DataType>String</DataType>
<Prompt>ServerName</Prompt>
</ReportParameter>
</ReportParameters>


You can also check this blog posting: http://blogs.msdn.com/bwelcker/archive/2005/04/29/413343.aspx

-- Robert

|||I can't get the 2005 solution for data source expressions to work if I need to use the stored proc command type. Keeps getting reset to text. Is this a bug?|||

Staceyd,

We ran into the same problem with RS 2005 when trying to use a DynamicSource with a stored procedure with the query type reverting to text.

We ended up just copying the stored procedure as the text based query . This of course means that every report that would normally based off of one stored procedure has to be individually modified if we need to add or subtract fields.

Yes we ended up with our Dynamic connection string, but we also added to our maintenance headache.

Build your report with the stored procedure as its dataset, make sure it runs the way you want it to, then:

1. Create a report parameter "ConnectionString", make sure that this parameter is listed at the top of the parameter list. <example: two existing parameters BeginDate and EndDate, when you add ConnectionString Parameter, move it to the top of the list>

2. If you are planning to have interactivity with another report either via graphs or navigation, create a calculated field in the data set called ConnectionString and make its expression value the ConnectionString Parameter. Use this field to pass the connection string to your external navigation link.

3. Create a new datasource called DynamicSource, for its connection string use the paramter you created earlier (=Parameters!ConnectionString.value). For the query string you have to paste in sql of your stored procedure.

4. Test the report.

If anyone finds another work around where the link to the actual stored procedure can be maintained without it reverting back to text based query, please speak up:)

|||

RS_Trans

thanks for the quick reply! And yes, if anyone has a method to do this without reverting back to text based query it would be appreciated, until then I will use that solution

|||Does it works?|||

OK. found it..

The data source must be report specific data source.

Regards,

Visu

|||

Hi,
I am new to Reporting Services. While browsing through the forums, I came across this posting.

Well I just wanted to know whether the above given solution works or not.

Please let me know.

Regards,
Sudhakara.T.P.

|||

This seems to work for SQL datasources....but what about XML datasources. I have a situation where I am getting data from a website that has data criteria in the request string (unfortunately, this is not exactly a webservice). So, I need to dynamically format the request string that is the ConnectString of the XML datasource.

Any thoughts?

|||

I tried the solution with a report specific data source and parametrizinf the connection string. I get the follwing error

'An error occured duing report processing.

Cannot connect to the data source.'

I checked the data base and the server name are correct.

Any pointers please?

|||

Can any one please explain more on the solution for dynamic data source connectivity in reporting services 2000

* Use the SOAP API by calling SetDataSourceContents?

If any one has implemented it, can you please provide a step wise pointer to how to get this done.

Will be of great help!

|||

Hi Friend

Did you able to get further information on SOAP API by calling SetDataSourceContents ? if yes please pass it to me

It would be really nice to have this info..

|||

Hi,

Can't seem to get the dynamic data source name to work either, yet we have a brand new SQL Server 2005 installation running with Reporting Services.

When I simply go to the Data tab to add the ="....." to my existing connection string (so I'm not even trying to use any report parameter at this stage), it still doesn't work as if it wouldn't interpret it correctly... could someone help? Is there a switch somewhere to trigger the data source expression in RS 2005?

Thanks in advance,

Xavier

PS: We run a french version...

|||

Ok, found the problem, for those of you who run into the same problem, (ie : '[BC32017] Comma, ')', or a valid expression continuation expected.'.), you might want to make sure there's no space in your Data Source Name, that was the problem for me...

Good luck!

Xavier

Dynamic data source name...

Sorry if this is a pretty basic question.. but my team here is working on SQL Reporting app for the first time.

is it possible to put the data source name/connection string in a config file (like web.config) and have the reports use that from there? What is the standard way of doing this while trying to deploy the reports on different servers?

Thanks

Various approaches for dynamic database connections in RS 2000 are available:
* Use a custom data processing extension
http://msdn.microsoft.com/library/en-us/RSPROG/htm/rsp_prog_extend_dataproc_5c2q.asp
* Use the SOAP API by calling SetDataSourceContents:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rsprog/htm/rsp_ref_soapapi_service_lz_2ojd.asp
* Use the linked server functionality of SQL Server; please check this thread:
http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.sqlserver.reportingsvcs&mid=848bac6b-98a2-4de7-abfd-bf199a99b660&sloc=en-us
* If the databases are on the same server, use a dynamic query text (i.e. ="select * from " & Parameters!DatabaseName.Value & "..table")
* If you're just toggling between two or three databases, you can publish the same report 3 times with 3 different names using 3 different data sources and write a main report that shows/hides the correct subreport based on whatever criteria you want.

In addition, native support (expression-based connection strings) is available in RS 2005: Finish the design of the datasets with a constant connection string and make sure everything works. Then, go back to the data tab and open the dataset/data source dialog and change the connection string to be an expression. Use string concatenation to plug in the parameter value. Here is an example of how the RDL would look for a parameter-based connection string:
<DataSources>
<DataSource Name="Northwind">
<ConnectionProperties>
<DataProvider>SQL</DataProvider>
<ConnectString>="data source=" &amp; Parameters!ServerName.Value &amp; ";initial catalog=Northwind;"</ConnectString>
<IntegratedSecurity>true</IntegratedSecurity>
</ConnectionProperties>
</DataSource>
</DataSources>

<ReportParameters>
<ReportParameter Name="ServerName">
<DataType>String</DataType>
<Prompt>ServerName</Prompt>
</ReportParameter>
</ReportParameters>


You can also check this blog posting: http://blogs.msdn.com/bwelcker/archive/2005/04/29/413343.aspx

-- Robert

|||I can't get the 2005 solution for data source expressions to work if I need to use the stored proc command type. Keeps getting reset to text. Is this a bug?|||

Staceyd,

We ran into the same problem with RS 2005 when trying to use a DynamicSource with a stored procedure with the query type reverting to text.

We ended up just copying the stored procedure as the text based query . This of course means that every report that would normally based off of one stored procedure has to be individually modified if we need to add or subtract fields.

Yes we ended up with our Dynamic connection string, but we also added to our maintenance headache.

Build your report with the stored procedure as its dataset, make sure it runs the way you want it to, then:

1. Create a report parameter "ConnectionString", make sure that this parameter is listed at the top of the parameter list. <example: two existing parameters BeginDate and EndDate, when you add ConnectionString Parameter, move it to the top of the list>

2. If you are planning to have interactivity with another report either via graphs or navigation, create a calculated field in the data set called ConnectionString and make its expression value the ConnectionString Parameter. Use this field to pass the connection string to your external navigation link.

3. Create a new datasource called DynamicSource, for its connection string use the paramter you created earlier (=Parameters!ConnectionString.value). For the query string you have to paste in sql of your stored procedure.

4. Test the report.

If anyone finds another work around where the link to the actual stored procedure can be maintained without it reverting back to text based query, please speak up:)

|||

RS_Trans

thanks for the quick reply! And yes, if anyone has a method to do this without reverting back to text based query it would be appreciated, until then I will use that solution

|||Does it works?|||

OK. found it..

The data source must be report specific data source.

Regards,

Visu

|||

Hi,
I am new to Reporting Services. While browsing through the forums, I came across this posting.

Well I just wanted to know whether the above given solution works or not.

Please let me know.

Regards,
Sudhakara.T.P.

|||

This seems to work for SQL datasources....but what about XML datasources. I have a situation where I am getting data from a website that has data criteria in the request string (unfortunately, this is not exactly a webservice). So, I need to dynamically format the request string that is the ConnectString of the XML datasource.

Any thoughts?

|||

I tried the solution with a report specific data source and parametrizinf the connection string. I get the follwing error

'An error occured duing report processing.

Cannot connect to the data source.'

I checked the data base and the server name are correct.

Any pointers please?

|||

Can any one please explain more on the solution for dynamic data source connectivity in reporting services 2000

* Use the SOAP API by calling SetDataSourceContents?

If any one has implemented it, can you please provide a step wise pointer to how to get this done.

Will be of great help!

|||

Hi Friend

Did you able to get further information on SOAP API by calling SetDataSourceContents ? if yes please pass it to me

It would be really nice to have this info..

|||

Hi,

Can't seem to get the dynamic data source name to work either, yet we have a brand new SQL Server 2005 installation running with Reporting Services.

When I simply go to the Data tab to add the ="....." to my existing connection string (so I'm not even trying to use any report parameter at this stage), it still doesn't work as if it wouldn't interpret it correctly... could someone help? Is there a switch somewhere to trigger the data source expression in RS 2005?

Thanks in advance,

Xavier

PS: We run a french version...

|||

Ok, found the problem, for those of you who run into the same problem, (ie : '[BC32017] Comma, ')', or a valid expression continuation expected.'.), you might want to make sure there's no space in your Data Source Name, that was the problem for me...

Good luck!

Xavier

Dynamic data source name...

Sorry if this is a pretty basic question.. but my team here is working on SQL Reporting app for the first time.

is it possible to put the data source name/connection string in a config file (like web.config) and have the reports use that from there? What is the standard way of doing this while trying to deploy the reports on different servers?

Thanks

Various approaches for dynamic database connections in RS 2000 are available:
* Use a custom data processing extension
http://msdn.microsoft.com/library/en-us/RSPROG/htm/rsp_prog_extend_dataproc_5c2q.asp
* Use the SOAP API by calling SetDataSourceContents:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rsprog/htm/rsp_ref_soapapi_service_lz_2ojd.asp
* Use the linked server functionality of SQL Server; please check this thread:
http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.sqlserver.reportingsvcs&mid=848bac6b-98a2-4de7-abfd-bf199a99b660&sloc=en-us
* If the databases are on the same server, use a dynamic query text (i.e. ="select * from " & Parameters!DatabaseName.Value & "..table")
* If you're just toggling between two or three databases, you can publish the same report 3 times with 3 different names using 3 different data sources and write a main report that shows/hides the correct subreport based on whatever criteria you want.

In addition, native support (expression-based connection strings) is available in RS 2005: Finish the design of the datasets with a constant connection string and make sure everything works. Then, go back to the data tab and open the dataset/data source dialog and change the connection string to be an expression. Use string concatenation to plug in the parameter value. Here is an example of how the RDL would look for a parameter-based connection string:
<DataSources>
<DataSource Name="Northwind">
<ConnectionProperties>
<DataProvider>SQL</DataProvider>
<ConnectString>="data source=" &amp; Parameters!ServerName.Value &amp; ";initial catalog=Northwind;"</ConnectString>
<IntegratedSecurity>true</IntegratedSecurity>
</ConnectionProperties>
</DataSource>
</DataSources>

<ReportParameters>
<ReportParameter Name="ServerName">
<DataType>String</DataType>
<Prompt>ServerName</Prompt>
</ReportParameter>
</ReportParameters>


You can also check this blog posting: http://blogs.msdn.com/bwelcker/archive/2005/04/29/413343.aspx

-- Robert

|||I can't get the 2005 solution for data source expressions to work if I need to use the stored proc command type. Keeps getting reset to text. Is this a bug?|||

Staceyd,

We ran into the same problem with RS 2005 when trying to use a DynamicSource with a stored procedure with the query type reverting to text.

We ended up just copying the stored procedure as the text based query . This of course means that every report that would normally based off of one stored procedure has to be individually modified if we need to add or subtract fields.

Yes we ended up with our Dynamic connection string, but we also added to our maintenance headache.

Build your report with the stored procedure as its dataset, make sure it runs the way you want it to, then:

1. Create a report parameter "ConnectionString", make sure that this parameter is listed at the top of the parameter list. <example: two existing parameters BeginDate and EndDate, when you add ConnectionString Parameter, move it to the top of the list>

2. If you are planning to have interactivity with another report either via graphs or navigation, create a calculated field in the data set called ConnectionString and make its expression value the ConnectionString Parameter. Use this field to pass the connection string to your external navigation link.

3. Create a new datasource called DynamicSource, for its connection string use the paramter you created earlier (=Parameters!ConnectionString.value). For the query string you have to paste in sql of your stored procedure.

4. Test the report.

If anyone finds another work around where the link to the actual stored procedure can be maintained without it reverting back to text based query, please speak up:)

|||

RS_Trans

thanks for the quick reply! And yes, if anyone has a method to do this without reverting back to text based query it would be appreciated, until then I will use that solution

|||Does it works?|||

OK. found it..

The data source must be report specific data source.

Regards,

Visu

|||

Hi,
I am new to Reporting Services. While browsing through the forums, I came across this posting.

Well I just wanted to know whether the above given solution works or not.

Please let me know.

Regards,
Sudhakara.T.P.

|||

This seems to work for SQL datasources....but what about XML datasources. I have a situation where I am getting data from a website that has data criteria in the request string (unfortunately, this is not exactly a webservice). So, I need to dynamically format the request string that is the ConnectString of the XML datasource.

Any thoughts?

|||

I tried the solution with a report specific data source and parametrizinf the connection string. I get the follwing error

'An error occured duing report processing.

Cannot connect to the data source.'

I checked the data base and the server name are correct.

Any pointers please?

|||

Can any one please explain more on the solution for dynamic data source connectivity in reporting services 2000

* Use the SOAP API by calling SetDataSourceContents?

If any one has implemented it, can you please provide a step wise pointer to how to get this done.

Will be of great help!

|||

Hi Friend

Did you able to get further information on SOAP API by calling SetDataSourceContents ? if yes please pass it to me

It would be really nice to have this info..

|||

Hi,

Can't seem to get the dynamic data source name to work either, yet we have a brand new SQL Server 2005 installation running with Reporting Services.

When I simply go to the Data tab to add the ="....." to my existing connection string (so I'm not even trying to use any report parameter at this stage), it still doesn't work as if it wouldn't interpret it correctly... could someone help? Is there a switch somewhere to trigger the data source expression in RS 2005?

Thanks in advance,

Xavier

PS: We run a french version...

|||

Ok, found the problem, for those of you who run into the same problem, (ie : '[BC32017] Comma, ')', or a valid expression continuation expected.'.), you might want to make sure there's no space in your Data Source Name, that was the problem for me...

Good luck!

Xavier

Dynamic data source name...

Sorry if this is a pretty basic question.. but my team here is working on SQL Reporting app for the first time.

is it possible to put the data source name/connection string in a config file (like web.config) and have the reports use that from there? What is the standard way of doing this while trying to deploy the reports on different servers?

Thanks

Various approaches for dynamic database connections in RS 2000 are available:
* Use a custom data processing extension
http://msdn.microsoft.com/library/en-us/RSPROG/htm/rsp_prog_extend_dataproc_5c2q.asp
* Use the SOAP API by calling SetDataSourceContents:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rsprog/htm/rsp_ref_soapapi_service_lz_2ojd.asp
* Use the linked server functionality of SQL Server; please check this thread:
http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.sqlserver.reportingsvcs&mid=848bac6b-98a2-4de7-abfd-bf199a99b660&sloc=en-us
* If the databases are on the same server, use a dynamic query text (i.e. ="select * from " & Parameters!DatabaseName.Value & "..table")
* If you're just toggling between two or three databases, you can publish the same report 3 times with 3 different names using 3 different data sources and write a main report that shows/hides the correct subreport based on whatever criteria you want.

In addition, native support (expression-based connection strings) is available in RS 2005: Finish the design of the datasets with a constant connection string and make sure everything works. Then, go back to the data tab and open the dataset/data source dialog and change the connection string to be an expression. Use string concatenation to plug in the parameter value. Here is an example of how the RDL would look for a parameter-based connection string:
<DataSources>
<DataSource Name="Northwind">
<ConnectionProperties>
<DataProvider>SQL</DataProvider>
<ConnectString>="data source=" &amp; Parameters!ServerName.Value &amp; ";initial catalog=Northwind;"</ConnectString>
<IntegratedSecurity>true</IntegratedSecurity>
</ConnectionProperties>
</DataSource>
</DataSources>

<ReportParameters>
<ReportParameter Name="ServerName">
<DataType>String</DataType>
<Prompt>ServerName</Prompt>
</ReportParameter>
</ReportParameters>


You can also check this blog posting: http://blogs.msdn.com/bwelcker/archive/2005/04/29/413343.aspx

-- Robert

|||I can't get the 2005 solution for data source expressions to work if I need to use the stored proc command type. Keeps getting reset to text. Is this a bug?|||

Staceyd,

We ran into the same problem with RS 2005 when trying to use a DynamicSource with a stored procedure with the query type reverting to text.

We ended up just copying the stored procedure as the text based query . This of course means that every report that would normally based off of one stored procedure has to be individually modified if we need to add or subtract fields.

Yes we ended up with our Dynamic connection string, but we also added to our maintenance headache.

Build your report with the stored procedure as its dataset, make sure it runs the way you want it to, then:

1. Create a report parameter "ConnectionString", make sure that this parameter is listed at the top of the parameter list. <example: two existing parameters BeginDate and EndDate, when you add ConnectionString Parameter, move it to the top of the list>

2. If you are planning to have interactivity with another report either via graphs or navigation, create a calculated field in the data set called ConnectionString and make its expression value the ConnectionString Parameter. Use this field to pass the connection string to your external navigation link.

3. Create a new datasource called DynamicSource, for its connection string use the paramter you created earlier (=Parameters!ConnectionString.value). For the query string you have to paste in sql of your stored procedure.

4. Test the report.

If anyone finds another work around where the link to the actual stored procedure can be maintained without it reverting back to text based query, please speak up:)

|||

RS_Trans

thanks for the quick reply! And yes, if anyone has a method to do this without reverting back to text based query it would be appreciated, until then I will use that solution

|||Does it works?|||

OK. found it..

The data source must be report specific data source.

Regards,

Visu

|||

Hi,
I am new to Reporting Services. While browsing through the forums, I came across this posting.

Well I just wanted to know whether the above given solution works or not.

Please let me know.

Regards,
Sudhakara.T.P.

|||

This seems to work for SQL datasources....but what about XML datasources. I have a situation where I am getting data from a website that has data criteria in the request string (unfortunately, this is not exactly a webservice). So, I need to dynamically format the request string that is the ConnectString of the XML datasource.

Any thoughts?

|||

I tried the solution with a report specific data source and parametrizinf the connection string. I get the follwing error

'An error occured duing report processing.

Cannot connect to the data source.'

I checked the data base and the server name are correct.

Any pointers please?

|||

Can any one please explain more on the solution for dynamic data source connectivity in reporting services 2000

* Use the SOAP API by calling SetDataSourceContents?

If any one has implemented it, can you please provide a step wise pointer to how to get this done.

Will be of great help!

|||

Hi Friend

Did you able to get further information on SOAP API by calling SetDataSourceContents ? if yes please pass it to me

It would be really nice to have this info..

|||

Hi,

Can't seem to get the dynamic data source name to work either, yet we have a brand new SQL Server 2005 installation running with Reporting Services.

When I simply go to the Data tab to add the ="....." to my existing connection string (so I'm not even trying to use any report parameter at this stage), it still doesn't work as if it wouldn't interpret it correctly... could someone help? Is there a switch somewhere to trigger the data source expression in RS 2005?

Thanks in advance,

Xavier

PS: We run a french version...

|||

Ok, found the problem, for those of you who run into the same problem, (ie : '[BC32017] Comma, ')', or a valid expression continuation expected.'.), you might want to make sure there's no space in your Data Source Name, that was the problem for me...

Good luck!

Xavier

Dynamic data source name...

Sorry if this is a pretty basic question.. but my team here is working on SQL Reporting app for the first time.

is it possible to put the data source name/connection string in a config file (like web.config) and have the reports use that from there? What is the standard way of doing this while trying to deploy the reports on different servers?

Thanks

Various approaches for dynamic database connections in RS 2000 are available:
* Use a custom data processing extension
http://msdn.microsoft.com/library/en-us/RSPROG/htm/rsp_prog_extend_dataproc_5c2q.asp
* Use the SOAP API by calling SetDataSourceContents:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rsprog/htm/rsp_ref_soapapi_service_lz_2ojd.asp
* Use the linked server functionality of SQL Server; please check this thread:
http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.sqlserver.reportingsvcs&mid=848bac6b-98a2-4de7-abfd-bf199a99b660&sloc=en-us
* If the databases are on the same server, use a dynamic query text (i.e. ="select * from " & Parameters!DatabaseName.Value & "..table")
* If you're just toggling between two or three databases, you can publish the same report 3 times with 3 different names using 3 different data sources and write a main report that shows/hides the correct subreport based on whatever criteria you want.

In addition, native support (expression-based connection strings) is available in RS 2005: Finish the design of the datasets with a constant connection string and make sure everything works. Then, go back to the data tab and open the dataset/data source dialog and change the connection string to be an expression. Use string concatenation to plug in the parameter value. Here is an example of how the RDL would look for a parameter-based connection string:
<DataSources>
<DataSource Name="Northwind">
<ConnectionProperties>
<DataProvider>SQL</DataProvider>
<ConnectString>="data source=" &amp; Parameters!ServerName.Value &amp; ";initial catalog=Northwind;"</ConnectString>
<IntegratedSecurity>true</IntegratedSecurity>
</ConnectionProperties>
</DataSource>
</DataSources>

<ReportParameters>
<ReportParameter Name="ServerName">
<DataType>String</DataType>
<Prompt>ServerName</Prompt>
</ReportParameter>
</ReportParameters>


You can also check this blog posting: http://blogs.msdn.com/bwelcker/archive/2005/04/29/413343.aspx

-- Robert

|||I can't get the 2005 solution for data source expressions to work if I need to use the stored proc command type. Keeps getting reset to text. Is this a bug?|||

Staceyd,

We ran into the same problem with RS 2005 when trying to use a DynamicSource with a stored procedure with the query type reverting to text.

We ended up just copying the stored procedure as the text based query . This of course means that every report that would normally based off of one stored procedure has to be individually modified if we need to add or subtract fields.

Yes we ended up with our Dynamic connection string, but we also added to our maintenance headache.

Build your report with the stored procedure as its dataset, make sure it runs the way you want it to, then:

1. Create a report parameter "ConnectionString", make sure that this parameter is listed at the top of the parameter list. <example: two existing parameters BeginDate and EndDate, when you add ConnectionString Parameter, move it to the top of the list>

2. If you are planning to have interactivity with another report either via graphs or navigation, create a calculated field in the data set called ConnectionString and make its expression value the ConnectionString Parameter. Use this field to pass the connection string to your external navigation link.

3. Create a new datasource called DynamicSource, for its connection string use the paramter you created earlier (=Parameters!ConnectionString.value). For the query string you have to paste in sql of your stored procedure.

4. Test the report.

If anyone finds another work around where the link to the actual stored procedure can be maintained without it reverting back to text based query, please speak up:)

|||

RS_Trans

thanks for the quick reply! And yes, if anyone has a method to do this without reverting back to text based query it would be appreciated, until then I will use that solution

|||Does it works?|||

OK. found it..

The data source must be report specific data source.

Regards,

Visu

|||

Hi,
I am new to Reporting Services. While browsing through the forums, I came across this posting.

Well I just wanted to know whether the above given solution works or not.

Please let me know.

Regards,
Sudhakara.T.P.

|||

This seems to work for SQL datasources....but what about XML datasources. I have a situation where I am getting data from a website that has data criteria in the request string (unfortunately, this is not exactly a webservice). So, I need to dynamically format the request string that is the ConnectString of the XML datasource.

Any thoughts?

|||

I tried the solution with a report specific data source and parametrizinf the connection string. I get the follwing error

'An error occured duing report processing.

Cannot connect to the data source.'

I checked the data base and the server name are correct.

Any pointers please?

|||

Can any one please explain more on the solution for dynamic data source connectivity in reporting services 2000

* Use the SOAP API by calling SetDataSourceContents?

If any one has implemented it, can you please provide a step wise pointer to how to get this done.

Will be of great help!

|||

Hi Friend

Did you able to get further information on SOAP API by calling SetDataSourceContents ? if yes please pass it to me

It would be really nice to have this info..

|||

Hi,

Can't seem to get the dynamic data source name to work either, yet we have a brand new SQL Server 2005 installation running with Reporting Services.

When I simply go to the Data tab to add the ="....." to my existing connection string (so I'm not even trying to use any report parameter at this stage), it still doesn't work as if it wouldn't interpret it correctly... could someone help? Is there a switch somewhere to trigger the data source expression in RS 2005?

Thanks in advance,

Xavier

PS: We run a french version...

|||

Ok, found the problem, for those of you who run into the same problem, (ie : '[BC32017] Comma, ')', or a valid expression continuation expected.'.), you might want to make sure there's no space in your Data Source Name, that was the problem for me...

Good luck!

Xavier

Dynamic data source name...

Sorry if this is a pretty basic question.. but my team here is working on SQL Reporting app for the first time.

is it possible to put the data source name/connection string in a config file (like web.config) and have the reports use that from there? What is the standard way of doing this while trying to deploy the reports on different servers?

Thanks

Various approaches for dynamic database connections in RS 2000 are available:
* Use a custom data processing extension
http://msdn.microsoft.com/library/en-us/RSPROG/htm/rsp_prog_extend_dataproc_5c2q.asp
* Use the SOAP API by calling SetDataSourceContents:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rsprog/htm/rsp_ref_soapapi_service_lz_2ojd.asp
* Use the linked server functionality of SQL Server; please check this thread:
http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.sqlserver.reportingsvcs&mid=848bac6b-98a2-4de7-abfd-bf199a99b660&sloc=en-us
* If the databases are on the same server, use a dynamic query text (i.e. ="select * from " & Parameters!DatabaseName.Value & "..table")
* If you're just toggling between two or three databases, you can publish the same report 3 times with 3 different names using 3 different data sources and write a main report that shows/hides the correct subreport based on whatever criteria you want.

In addition, native support (expression-based connection strings) is available in RS 2005: Finish the design of the datasets with a constant connection string and make sure everything works. Then, go back to the data tab and open the dataset/data source dialog and change the connection string to be an expression. Use string concatenation to plug in the parameter value. Here is an example of how the RDL would look for a parameter-based connection string:
<DataSources>
<DataSource Name="Northwind">
<ConnectionProperties>
<DataProvider>SQL</DataProvider>
<ConnectString>="data source=" &amp; Parameters!ServerName.Value &amp; ";initial catalog=Northwind;"</ConnectString>
<IntegratedSecurity>true</IntegratedSecurity>
</ConnectionProperties>
</DataSource>
</DataSources>

<ReportParameters>
<ReportParameter Name="ServerName">
<DataType>String</DataType>
<Prompt>ServerName</Prompt>
</ReportParameter>
</ReportParameters>


You can also check this blog posting: http://blogs.msdn.com/bwelcker/archive/2005/04/29/413343.aspx

-- Robert

|||I can't get the 2005 solution for data source expressions to work if I need to use the stored proc command type. Keeps getting reset to text. Is this a bug?|||

Staceyd,

We ran into the same problem with RS 2005 when trying to use a DynamicSource with a stored procedure with the query type reverting to text.

We ended up just copying the stored procedure as the text based query . This of course means that every report that would normally based off of one stored procedure has to be individually modified if we need to add or subtract fields.

Yes we ended up with our Dynamic connection string, but we also added to our maintenance headache.

Build your report with the stored procedure as its dataset, make sure it runs the way you want it to, then:

1. Create a report parameter "ConnectionString", make sure that this parameter is listed at the top of the parameter list. <example: two existing parameters BeginDate and EndDate, when you add ConnectionString Parameter, move it to the top of the list>

2. If you are planning to have interactivity with another report either via graphs or navigation, create a calculated field in the data set called ConnectionString and make its expression value the ConnectionString Parameter. Use this field to pass the connection string to your external navigation link.

3. Create a new datasource called DynamicSource, for its connection string use the paramter you created earlier (=Parameters!ConnectionString.value). For the query string you have to paste in sql of your stored procedure.

4. Test the report.

If anyone finds another work around where the link to the actual stored procedure can be maintained without it reverting back to text based query, please speak up:)

|||

RS_Trans

thanks for the quick reply! And yes, if anyone has a method to do this without reverting back to text based query it would be appreciated, until then I will use that solution

|||Does it works?|||

OK. found it..

The data source must be report specific data source.

Regards,

Visu

|||

Hi,
I am new to Reporting Services. While browsing through the forums, I came across this posting.

Well I just wanted to know whether the above given solution works or not.

Please let me know.

Regards,
Sudhakara.T.P.

|||

This seems to work for SQL datasources....but what about XML datasources. I have a situation where I am getting data from a website that has data criteria in the request string (unfortunately, this is not exactly a webservice). So, I need to dynamically format the request string that is the ConnectString of the XML datasource.

Any thoughts?

|||

I tried the solution with a report specific data source and parametrizinf the connection string. I get the follwing error

'An error occured duing report processing.

Cannot connect to the data source.'

I checked the data base and the server name are correct.

Any pointers please?

|||

Can any one please explain more on the solution for dynamic data source connectivity in reporting services 2000

* Use the SOAP API by calling SetDataSourceContents?

If any one has implemented it, can you please provide a step wise pointer to how to get this done.

Will be of great help!

|||

Hi Friend

Did you able to get further information on SOAP API by calling SetDataSourceContents ? if yes please pass it to me

It would be really nice to have this info..

|||

Hi,

Can't seem to get the dynamic data source name to work either, yet we have a brand new SQL Server 2005 installation running with Reporting Services.

When I simply go to the Data tab to add the ="....." to my existing connection string (so I'm not even trying to use any report parameter at this stage), it still doesn't work as if it wouldn't interpret it correctly... could someone help? Is there a switch somewhere to trigger the data source expression in RS 2005?

Thanks in advance,

Xavier

PS: We run a french version...

|||

Ok, found the problem, for those of you who run into the same problem, (ie : '[BC32017] Comma, ')', or a valid expression continuation expected.'.), you might want to make sure there's no space in your Data Source Name, that was the problem for me...

Good luck!

Xavier

Dynamic data source name...

Sorry if this is a pretty basic question.. but my team here is working on SQL Reporting app for the first time.

is it possible to put the data source name/connection string in a config file (like web.config) and have the reports use that from there? What is the standard way of doing this while trying to deploy the reports on different servers?

Thanks

Various approaches for dynamic database connections in RS 2000 are available:
* Use a custom data processing extension
http://msdn.microsoft.com/library/en-us/RSPROG/htm/rsp_prog_extend_dataproc_5c2q.asp
* Use the SOAP API by calling SetDataSourceContents:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rsprog/htm/rsp_ref_soapapi_service_lz_2ojd.asp
* Use the linked server functionality of SQL Server; please check this thread:
http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.sqlserver.reportingsvcs&mid=848bac6b-98a2-4de7-abfd-bf199a99b660&sloc=en-us
* If the databases are on the same server, use a dynamic query text (i.e. ="select * from " & Parameters!DatabaseName.Value & "..table")
* If you're just toggling between two or three databases, you can publish the same report 3 times with 3 different names using 3 different data sources and write a main report that shows/hides the correct subreport based on whatever criteria you want.

In addition, native support (expression-based connection strings) is available in RS 2005: Finish the design of the datasets with a constant connection string and make sure everything works. Then, go back to the data tab and open the dataset/data source dialog and change the connection string to be an expression. Use string concatenation to plug in the parameter value. Here is an example of how the RDL would look for a parameter-based connection string:
<DataSources>
<DataSource Name="Northwind">
<ConnectionProperties>
<DataProvider>SQL</DataProvider>
<ConnectString>="data source=" &amp; Parameters!ServerName.Value &amp; ";initial catalog=Northwind;"</ConnectString>
<IntegratedSecurity>true</IntegratedSecurity>
</ConnectionProperties>
</DataSource>
</DataSources>

<ReportParameters>
<ReportParameter Name="ServerName">
<DataType>String</DataType>
<Prompt>ServerName</Prompt>
</ReportParameter>
</ReportParameters>


You can also check this blog posting: http://blogs.msdn.com/bwelcker/archive/2005/04/29/413343.aspx

-- Robert

|||I can't get the 2005 solution for data source expressions to work if I need to use the stored proc command type. Keeps getting reset to text. Is this a bug?|||

Staceyd,

We ran into the same problem with RS 2005 when trying to use a DynamicSource with a stored procedure with the query type reverting to text.

We ended up just copying the stored procedure as the text based query . This of course means that every report that would normally based off of one stored procedure has to be individually modified if we need to add or subtract fields.

Yes we ended up with our Dynamic connection string, but we also added to our maintenance headache.

Build your report with the stored procedure as its dataset, make sure it runs the way you want it to, then:

1. Create a report parameter "ConnectionString", make sure that this parameter is listed at the top of the parameter list. <example: two existing parameters BeginDate and EndDate, when you add ConnectionString Parameter, move it to the top of the list>

2. If you are planning to have interactivity with another report either via graphs or navigation, create a calculated field in the data set called ConnectionString and make its expression value the ConnectionString Parameter. Use this field to pass the connection string to your external navigation link.

3. Create a new datasource called DynamicSource, for its connection string use the paramter you created earlier (=Parameters!ConnectionString.value). For the query string you have to paste in sql of your stored procedure.

4. Test the report.

If anyone finds another work around where the link to the actual stored procedure can be maintained without it reverting back to text based query, please speak up:)

|||

RS_Trans

thanks for the quick reply! And yes, if anyone has a method to do this without reverting back to text based query it would be appreciated, until then I will use that solution

|||Does it works?|||

OK. found it..

The data source must be report specific data source.

Regards,

Visu

|||

Hi,
I am new to Reporting Services. While browsing through the forums, I came across this posting.

Well I just wanted to know whether the above given solution works or not.

Please let me know.

Regards,
Sudhakara.T.P.

|||

This seems to work for SQL datasources....but what about XML datasources. I have a situation where I am getting data from a website that has data criteria in the request string (unfortunately, this is not exactly a webservice). So, I need to dynamically format the request string that is the ConnectString of the XML datasource.

Any thoughts?

|||

I tried the solution with a report specific data source and parametrizinf the connection string. I get the follwing error

'An error occured duing report processing.

Cannot connect to the data source.'

I checked the data base and the server name are correct.

Any pointers please?

|||

Can any one please explain more on the solution for dynamic data source connectivity in reporting services 2000

* Use the SOAP API by calling SetDataSourceContents?

If any one has implemented it, can you please provide a step wise pointer to how to get this done.

Will be of great help!

|||

Hi Friend

Did you able to get further information on SOAP API by calling SetDataSourceContents ? if yes please pass it to me

It would be really nice to have this info..

|||

Hi,

Can't seem to get the dynamic data source name to work either, yet we have a brand new SQL Server 2005 installation running with Reporting Services.

When I simply go to the Data tab to add the ="....." to my existing connection string (so I'm not even trying to use any report parameter at this stage), it still doesn't work as if it wouldn't interpret it correctly... could someone help? Is there a switch somewhere to trigger the data source expression in RS 2005?

Thanks in advance,

Xavier

PS: We run a french version...

|||

Ok, found the problem, for those of you who run into the same problem, (ie : '[BC32017] Comma, ')', or a valid expression continuation expected.'.), you might want to make sure there's no space in your Data Source Name, that was the problem for me...

Good luck!

Xavier

Sunday, February 19, 2012

Dynamic columns for Flat File destination?

I have a database app, and we're implementing various data export features using SSIS.

Basically, it's a couple of straight extracts of various recordsets/views, etc. to CSV (flat files) from our SQL Server 2005 database, so I'm creating an SSIS package for each of these datasets.

So far, so good, but my problem comes here: My requirements call for users to select from a list of available columns the fields that they want to include in their exported file. Then, the package should run, but only output the columns specified by the user.

Does anyone have any idea as to the best way to accomplish this? To recap, at design time, I know which columns the users will have to choose from, but at run time, they will specify the columns to export to the flat file.

Any help or guidance here is greatly appreciated

You will need to create the package programatically in order to acheive this.

http://msdn2.microsoft.com/en-us/library/ms345167.aspx is a good place to start.

Donald

|||

Thanks Donald... I have one more thing to ask. Is it possible to create and execute a package from scratch within a Script Task?

I really want to avoid scripting this stuff outside of the SSIS package (ie, in a VB.NET assembly), because my solution architecture depends on encapsulating all of the logic for SSIS stuff within the package.

If it's not possible from within a script task, could there possibly be another way to achieve this while preserving encapsulation of the logic within the SSIS package?

|||

Yes it is possible to do it in a script task. the code is exactly the same as if you were doing it outside of SSIS (as long as you were using VB.Net of course :)

The best example I have seen so far is here: http://www.gotdotnet.com/codegallery/codegallery.aspx?id=042f5bda-78c6-4c94-a68e-c1917b036db3 Click on "Create Packages Dynamically" in the bottom right hand corner.

-Jamie

|||

Hi Jamie,

again, thanks for the reply... While that code is indeed a fine example of creating packages programmatically, there's a bit of a problem with trying to replicate it inside of SSIS.

That code sample (as well as pretty much all others I've found for building packages programatically) imports the Microsoft.SqlServer.Dts.Runtime.Wrapper and the rosoft.SqlServer.Dts.Pipeline.Wrapper namespaces. Apparently neither of these namespaces are available from within a SSIS script task. The VSA IDE won't let me add references to the assemblies containing these namespaces.

Is there something else I'm missing?

|||

It is not possible to create packages or new objects within packages using SSIS.

You may be able to build the functionality into an assembly which could be called from a script - but you'll need to deploy the assembly separately.

Donald

|||

Oops, I didn't know that! Sorry J Nail!

If I were you I would build it innto a custom task. Its not that difficult - not that much harder then doing it in the script task.

-Jamie