Showing posts with label via. Show all posts
Showing posts with label via. Show all posts

Friday, March 30, 2012

How to Verify a DB via OLEDB?

I cannot find any OLE DB reference material for how to perform a "Verify" DB as advertised in the Documentation for SQL Server Mobile Edition.

The docs have a sample in C#, but nothing for OLD DB in C++.

Does anyone know how to do this?

Unfortunately it's not exposed through OLEDB. You can do other things like Repair, UpgradeDatabase etc through ISSCEEngine. Sample code would be

extern "C" int __cdecl wmain(){

HRESULT hr = NOERROR;
ISSCEEngine *pISSCEEngine = NULL;
VerifyResult(CoInitialize(NULL));
VerifyResult(CoCreateInstance(CLSID_Engine, NULL, CLSCTX_INPROC_SERVER,
IID_ISSCEEngine, (void**)&pISSCEEngine));

WCHAR *wszSrc=L"Data Source = src.sdf";
WCHAR *wszDst=L"Data Source = dst.sdf";
VerifyResult(pISSCEEngine->CompactDatabase(wszSrc, wszDst));

WCHAR *wszNew=L"Data Source = new.sdf";
VerifyResult(pISSCEEngine->CreateDatabase(wszNew));


Exit:
RELEASE(pISSCEEngine);
CoUninitialize();
return hr;
}

Thanks

Raja

P.S: Please mark the question as answered if your satisfied with the answer.

Wednesday, March 28, 2012

How to use variables for server connections

Hello,

Today is day two of using SSIS and having some issues adjusting. In DTS I would simply populate my global variables via an Active X step or pass them in at the job line.

I am having a hard time being able to do either or in SSIS. Really all I want to be able to do is pass in a server name to the Connection of an execute SQL task from a scheduled job line.

Same goes for any variable really ... how do I pass them in, and how do I assign them to specific areas of a task?

Thanks!

Mr.Bean wrote:

Hello,

Today is day two of using SSIS and having some issues adjusting. In DTS I would simply populate my global variables via an Active X step or pass them in at the job line.

I am having a hard time being able to do either or in SSIS. Really all I want to be able to do is pass in a server name to the Connection of an execute SQL task from a scheduled job line.

Same goes for any variable really ... how do I pass them in, and how do I assign them to specific areas of a task?

Thanks!

If you want to pass values into the package from the command-line then use the /SET option of dtexec.exe.

Does that answer the question?

By the way, the most analogous thing to populating global variables from an ActiveX Script is to do it in a Script Task. Don't use the ActiveX Script in SSIS - it isn't useful. The following post explains how you do it using a script task:

Writing to a variable from a script task
(http://blogs.conchango.com/jamiethomson/archive/2005/02/09/964.aspx)

Get all of that working first and then we can address "how do I assign them to specific areas of a task" (short answer - use expressions).

-Jamie

|||

By the way, if you're finding the transition from DTS difficult I've got some documentation that may help:

The mind-shift from DTS
(http://blogs.conchango.com/jamiethomson/archive/2005/05/09/1396.aspx)

But it used to work in DTS (1) - Modifing a Package in script
(http://blogs.conchango.com/jamiethomson/archive/2006/06/28/4156.aspx)

DTS Connections and SSIS Connection Managers
(http://blogs.conchango.com/jamiethomson/archive/2006/04/02/3422.aspx)

The new ETL Paradigm
(http://blogs.conchango.com/jamiethomson/archive/2005/02/15/1002.aspx)

-Jamie

|||So now what I'm reading here ...

http://www.databasejournal.com/features/mssql/article.php/3509601

DTExec /FILE SamplePackage.dtsx /SET \Package.Connections[ConnectionID].InitialCatalog;tempdb

Is really the intended way to pass in server names? What if (like in several of my processes) I connect to multiple servers for different steps? I really have to retrieve the GUID of those tasks and populate them appropriately like above?

I'm just now starting to look into the Package Configurations ... not sure what I'm doin here just yet, but would this be a better solution?

I miss DTS ...|||

Mr.Bean wrote:

So now what I'm reading here ...

http://www.databasejournal.com/features/mssql/article.php/3509601

DTExec /FILE SamplePackage.dtsx /SET \Package.Connections[ConnectionID].InitialCatalog;tempdb

Is really the intended way to pass in server names?

Someties yes. Sometimes no. Depends on your scenario.

Mr.Bean wrote:

What if (like in several of my processes) I connect to multiple servers for different steps?

Then you'll have multiple connection managers.

Mr.Bean wrote:

I really have to retrieve the GUID of those tasks and populate them appropriately like above?

Not sure I understand what you mean. You never have to know about task GUIDs.

Mr.Bean wrote:

I'm just now starting to look into the Package Configurations ... not sure what I'm doin here just yet, but would this be a better solution?

Possibly. Depends on your scenario. Most people find that configurations are the way to go rather than passing in connectoin details from the command-line.

Mr.Bean wrote:

I miss DTS ...

Well there is a steep learning curve with SSIS but most people find it worth it when they get there. Configurations, for example, are wonderfully powerful and remove many of the headaches people have in DTS.

-Jamie

|||Many of my processes (including this one) are designed to be very generic so that I can dynamically set specific items ... such as server name, database names, etc.

So the current SSIS package I'm working on, I have built and ready to go, but am struggling to find the best way to allow for dynamic variables (server/dbnames). Right now everything is static and it works ... but I need to change that.

Just built my first package configuration, and this might be what I'm looking for? By selecting which tasks I want put into this configuration (such as variables and connections), this will properly update those areas?

My wording isn't the greatest ... as I said, day two and not doing so well with this yet.

Thanks again|||

Mr.Bean wrote:

Many of my processes (including this one) are designed to be very generic so that I can dynamically set specific items ... such as server name, database names, etc.

So the current SSIS package I'm working on, I have built and ready to go, but am struggling to find the best way to allow for dynamic variables (server/dbnames). Right now everything is static and it works ... but I need to change that.

Just built my first package configuration, and this might be what I'm looking for? By selecting which tasks I want put into this configuration (such as variables and connections), this will properly update those areas?

My wording isn't the greatest ... as I said, day two and not doing so well with this yet.

Thanks again

It sounds as though you want a generic package. Something that you can execute for multiple environments and effectively "parameterize" it on each execution. Is this correct? In this scenario you will probably want to pass in values using the /SET option of dtexec.exe. By the way, make it easy on yourself, pass in the value for the ConnectionString property, not a seperate property for ServerName/Catalog etc...

Configurations are more suited to moving packages through your dev/test/UAT/live environments.

-Jamie

|||Yeah that is more of what I am looking for ... so I guess that brings me to my next question.

How do I do that? For example ...

I have a variable called DBList. I want this variable to have database names passed in, what would my /SET command look like?

Then for the connections. Say I have a SourceServer and DestServer variable. Same question above applies here, but how do I bind a variable to the connection in the properties of a task?

Thanks again for all your help.|||

Mr.Bean wrote:

Yeah that is more of what I am looking for ... so I guess that brings me to my next question.

How do I do that? For example ...

I have a variable called DBList. I want this variable to have database names passed in, what would my /SET command look like?

Then for the connections. Say I have a SourceServer and DestServer variable. Same question above applies here, but how do I bind a variable to the connection in the properties of a task?

Thanks again for all your help.

You don't. You can reference the ConnectionString property of the connection manager directly from the command line. So your command-line would look something like:

dtexec.exe /FILE "C:\Package1.dtsx" /SET "\Package.Connections[conn_name].Properties[ConnectionString]";SomeValue

-Jamie

|||

Jamie Thomson wrote:

Mr.Bean wrote:

Yeah that is more of what I am looking for ... so I guess that brings me to my next question.

How do I do that? For example ...

I have a variable called DBList. I want this variable to have database names passed in, what would my /SET command look like?

Then for the connections. Say I have a SourceServer and DestServer variable. Same question above applies here, but how do I bind a variable to the connection in the properties of a task?

Thanks again for all your help.

You don't. You can reference the ConnectionString property of the connection manager directly from the command line. So your command-line would look something like:

dtexec.exe /FILE "C:\Package1.dtsx" /SET "\Package.Connections[conn_name].Properties[ConnectionString]";SomeValue

-Jamie

Sorry for all the questions ... but I'm not sure I follow you on that.

http://img382.imageshack.us/img382/3171/ssisconnectionpropsbx5.jpg

As you can see the connection at this execute SQL task has no specific name to it. This is the connection I want to be able to update dynamically. So are you stating to create a new connection to a server, and simply update that per your /SET example?

dtexec.exe /FILE "C:\Package1.dtsx" /SET "\Package.Connections[SERVERNAME].Properties[ConnectionString]";SERVERNAME

Thanks again|||

Mr.Bean wrote:

Jamie Thomson wrote:

Mr.Bean wrote:

Yeah that is more of what I am looking for ... so I guess that brings me to my next question.

How do I do that? For example ...

I have a variable called DBList. I want this variable to have database names passed in, what would my /SET command look like?

Then for the connections. Say I have a SourceServer and DestServer variable. Same question above applies here, but how do I bind a variable to the connection in the properties of a task?

Thanks again for all your help.

You don't. You can reference the ConnectionString property of the connection manager directly from the command line. So your command-line would look something like:

dtexec.exe /FILE "C:\Package1.dtsx" /SET "\Package.Connections[conn_name].Properties[ConnectionString]";SomeValue

-Jamie

Sorry for all the questions ... but I'm not sure I follow you on that.

http://img382.imageshack.us/img382/3171/ssisconnectionpropsbx5.jpg

As you can see the connection at this execute SQL task has no specific name to it. This is the connection I want to be able to update dynamically. So are you stating to create a new connection to a server, and simply update that per your /SET example?

dtexec.exe /FILE "C:\Package1.dtsx" /SET "\Package.Connections[SERVERNAME].Properties[ConnectionString]";SERVERNAME

Thanks again

Hmmm...seems to be a lack of understanding here. Tasks contain no knowledge about the sources they ultimately connect to. They have a reference to a connection manager - and THAT is where the details of the external data source (be a it a file, a database or whatever) reside.

In other words - forget about the task. You have to update the the ConnectionString property of the connection manager being used by the task.

-Jamie

|||I think I follow you on that ... but the fact is that I have to create a connection in the connection manager for the task to refrence correct? So that means I still have to set a static connection to a server in the connection manager as it does not allow me to create a blank OLE DB connection that can be populated from the command line (which is what I want to do), right?

Sorry for the confusion here.|||

Mr.Bean wrote:

I think I follow you on that ... but the fact is that I have to create a connection in the connection manager for the task to refrence correct?

Correct.

Mr.Bean wrote:

So that means I still have to set a static connection to a server in the connection manager as it does not allow me to create a blank OLE DB connection that can be populated from the command line (which is what I want to do), right?

Sorry for the confusion here.

No need to apologise!

You do need to set the ConnectionString property of the connection manager to SOMETHING, yes. You may say "Why do I need to do that if I'm going to change it anyway when I execute?" I think that's a legitimate complaint however I don't see it as a problem. If it IS a problem then you can put BIDS into offline mode by selecting 'Work Offline' on the 'SSIS' menu.

Hope that helps.

-Jamie

|||I see ... makes sense.

So in summary, does this looks about right?

/FILE "C:\Directory\Package.dtsx" /SET "\Package.Variables[User::DBList].Value";"“DB1, DB2, DB3“" /SET "\Package.Connections[SERVERNAMESRC].Properties[ConnectionString]";SERVERNAMESRC
/SET "\Package.Connections[SERVERNAMEDEST].Properties[ConnectionString]";SERVERNAMEDEST

Does the command line look right? Do I have to specify each /SET?

Thanks again for all your help, definitely made this easier and made me realize its time to sit down and do some reading!
|||

Mr.Bean wrote:

I see ... makes sense.

So in summary, does this looks about right?

/FILE "C:\Directory\Package.dtsx" /SET "\Package.Variables[User::DBList].Value";"“DB1, DB2, DB3“" /SET "\Package.Connections[SERVERNAMESRC].Properties[ConnectionString]";SERVERNAMESRC
/SET "\Package.Connections[SERVERNAMEDEST].Properties[ConnectionString]";SERVERNAMEDEST

Yes, it looks right. Only you can tell if it is or not. Note that the value you supply will have to eb a full connection string. check out http://www.connectionstrings.com or just cop and paste from those that you set up in the package and edit accordingly.

Mr.Bean wrote:

Does the command line look right? Do I have to specify each /SET?

Yes.

Mr.Bean wrote:

Thanks again for all your help, definitely made this easier and made me realize its time to sit down and do some reading!

No getting around that I'm afraid :)

By the way if you get to sorting this out I would appreciate your marking one of my posts as an answer. The search function takes that into account when it delivers search results.

-Jamie

Wednesday, March 21, 2012

how to use sql encryption via an asp site. is this correct?

ive been playing around with encryption, just encrypting a column with a symmetric key, and having that symmetric key encrypted with a cert, and all that , and it works well through the SSMS, but i want to know how that will be used if im using sql server as a back end database for an asp web site, or an application. does the sql server have to be protected with an SSL cert, and once a user has logged in, what would the steps be to view encrypted data?

lets say i have an asp.net site wtih forms authentication, where the username and password are checked against values stored in a table, all done via https so the password data cant fall into the wrong hands. once the user is authenticate this is my idea:

each user has a status, stored in the status column of the users table : Admin or RegularUser.

if the user status is an Admin, and clicks on something that returns encrypted data, a sproc checks the user has admin status and uses impersonation to impersonate a login that has control to use the encryption key that encrypted the data. so the data is returned unencrypted.

is this a valid way of using encryption via asp.net, or are their security issues?

|||

SSL protects the communication with the server; the encryption you experimented with is for protecting the data within the server. For the steps required to view the encrypted data, it is up to you to determine those in your database application - you can have the user manually decrypt or you can have him access the data via views that automatically decrypt.

Thanks
Laurentiu

|||

You can provide access to data via a view that automatically decrypts using decryptbykeyautocert, for example. You can then group your Admin users in a role and grant permissions to that role to use the key. Admin users would then be able to decrypt the data and see it; regular users would not be able to.

Thanks
Laurentiu

|||that makes sense. thanks. one thing though. as the only account to access the sql server is the account the website is running under, how can i grant different groups of users different security levels? could it be as simple as once they log into the site ( which checks they are in the users table and checks a col called SecurityLevel) and if they have a level of "Admin User", the site will call sprocs for them that uses impersonation of a login that has admin access, where as if they only have "standard User" security level, the site will call sprocs that uses a login with low priviledges via impersonation to get their data. is this a viable solution or is it a round about way of doing something that could be much easier?

Wednesday, March 7, 2012

How to use default values of parameters

My report has 6 parameters. 3 Of them are defined with default values. How can I via the webservice method use these default values? I am building the parameters dynamically. You can see that the first 3 parameters are filled in depending on the value selected in a dropdown box. With the last 3 I want to use the default values. Is this possible and how do I do this. When with the first 3 parameters, no value is selected in the dropdown box, the default values shouls also be used but this is not yet programmed. Can anyone help me with this?
ReportParameter[] parameters = null;
parameters = rs.GetReportParameters(reportPath, historyID, forRendering, reportHistoryParameters, credentials);
ParameterValue[] rptParameters = new ParameterValue[parameters.GetLength(0)];
int intParam = 0;
foreach (ReportParameter rp in parameters)
{
rptParameters[intParam] = new ParameterValue();
rptParameters[intParam].Name = rp.Name;
switch(rp.Name.ToUpper())
{
case "OPCO":
rptParameters[intParam].Value = this.Opco;
break;
case "CONFIGTYPEGROUP":
rptParameters[intParam].Value = this.ConfigtypeGroup;
break;
case "CONFIGTYPE":
rptParameters[intParam].Value = this.ConfigType;
break;
case "ERRORCODE":
rptParameters[intParam].Value = rp.DefaultValues.ToString(); break;
case "VISITDATETIME_FROM":
rptParameters[intParam].Value = rp.DefaultValues.ToString())
break;
case "VISITDATETIME_TO":
rptParameters[intParam].Value = rp.DefaultValues.ToString();
break;
}
intParam++;
}
firstPage = rs.Render( reportPath,
format,
null,
deviceInfo,
rptParameters,
null,
null,
out encoding,
out mimeType,
out reportHistoryParameters,
out warnings,
out streamIDs);I already found the solution.
I have to write:
rptParameters[intParam].Value = rp.DefaultValues[0].ToString();
in stead of:
rptParameters[intParam].Value = rp.DefaultValues.ToString();
This will give back the default value defined in the report
"Gert" wrote:
> My report has 6 parameters. 3 Of them are defined with default values. How can I via the webservice method use these default values? I am building the parameters dynamically. You can see that the first 3 parameters are filled in depending on the value selected in a dropdown box. With the last 3 I want to use the default values. Is this possible and how do I do this. When with the first 3 parameters, no value is selected in the dropdown box, the default values shouls also be used but this is not yet programmed. Can anyone help me with this?
> ReportParameter[] parameters = null;
> parameters = rs.GetReportParameters(reportPath, historyID, forRendering, reportHistoryParameters, credentials);
> ParameterValue[] rptParameters = new ParameterValue[parameters.GetLength(0)];
> int intParam = 0;
> foreach (ReportParameter rp in parameters)
> {
> rptParameters[intParam] = new ParameterValue();
> rptParameters[intParam].Name = rp.Name;
> switch(rp.Name.ToUpper())
> {
> case "OPCO":
> rptParameters[intParam].Value = this.Opco;
> break;
> case "CONFIGTYPEGROUP":
> rptParameters[intParam].Value = this.ConfigtypeGroup;
> break;
> case "CONFIGTYPE":
> rptParameters[intParam].Value = this.ConfigType;
> break;
> case "ERRORCODE":
> rptParameters[intParam].Value = rp.DefaultValues.ToString(); break;
> case "VISITDATETIME_FROM":
> rptParameters[intParam].Value = rp.DefaultValues.ToString())
> break;
> case "VISITDATETIME_TO":
> rptParameters[intParam].Value = rp.DefaultValues.ToString();
> break;
> }
> intParam++;
> }
> firstPage = rs.Render( reportPath,
> format,
> null,
> deviceInfo,
> rptParameters,
> null,
> null,
> out encoding,
> out mimeType,
> out reportHistoryParameters,
> out warnings,
> out streamIDs);|||If you want the server to use the current default values, then don't pass in
anything for this values. Only pass in the three parameters that don't have
defaults and the server will then use the current default value during
rendering.
--
-Daniel
This posting is provided "AS IS" with no warranties, and confers no rights.
"Gert" <Gert@.discussions.microsoft.com> wrote in message
news:66030BB4-9273-4AF1-B608-9B01F77ED7FD@.microsoft.com...
> I already found the solution.
> I have to write:
> rptParameters[intParam].Value = rp.DefaultValues[0].ToString();
> in stead of:
> rptParameters[intParam].Value = rp.DefaultValues.ToString();
> This will give back the default value defined in the report
>
> "Gert" wrote:
> > My report has 6 parameters. 3 Of them are defined with default values.
How can I via the webservice method use these default values? I am building
the parameters dynamically. You can see that the first 3 parameters are
filled in depending on the value selected in a dropdown box. With the last 3
I want to use the default values. Is this possible and how do I do this.
When with the first 3 parameters, no value is selected in the dropdown box,
the default values shouls also be used but this is not yet programmed. Can
anyone help me with this?
> >
> > ReportParameter[] parameters = null;
> >
> > parameters = rs.GetReportParameters(reportPath, historyID, forRendering,
reportHistoryParameters, credentials);
> >
> > ParameterValue[] rptParameters = new
ParameterValue[parameters.GetLength(0)];
> >
> > int intParam = 0;
> > foreach (ReportParameter rp in parameters)
> > {
> > rptParameters[intParam] = new ParameterValue();
> > rptParameters[intParam].Name = rp.Name;
> > switch(rp.Name.ToUpper())
> > {
> > case "OPCO":
> > rptParameters[intParam].Value = this.Opco;
> > break;
> > case "CONFIGTYPEGROUP":
> > rptParameters[intParam].Value = this.ConfigtypeGroup;
> > break;
> > case "CONFIGTYPE":
> > rptParameters[intParam].Value = this.ConfigType;
> > break;
> > case "ERRORCODE":
> > rptParameters[intParam].Value = rp.DefaultValues.ToString(); break;
> > case "VISITDATETIME_FROM":
> > rptParameters[intParam].Value = rp.DefaultValues.ToString())
> > break;
> > case "VISITDATETIME_TO":
> > rptParameters[intParam].Value = rp.DefaultValues.ToString();
> > break;
> > }
> >
> > intParam++;
> > }
> >
> > firstPage = rs.Render( reportPath,
> > format,
> > null,
> > deviceInfo,
> > rptParameters,
> > null,
> > null,
> > out encoding,
> > out mimeType,
> > out reportHistoryParameters,
> > out warnings,
> > out streamIDs);|||I can't use your option because I have to loop through all the report parameterss because I have different reports with different paramaters and I don't know in the beginning of the program for which parameter the user will select a value or not. If no value selected, the default value of the report is retrieved.
I use the following code and this works perfect. I use a Hash table(see below) to store the paramaters and its values if they are selected.
********************************************************
ReportParameter[] parameters = null;
parameters = rs.GetReportParameters(reportPath, historyID, forRendering, reportHistoryParameters, credentials);
ParameterValue[] rptParameters = new ParameterValue[parameters.GetLength(0)];
int intParam = 0;
foreach (ReportParameter rp in parameters)
{
rptParameters[intParam] = new ParameterValue();
rptParameters[intParam].Name = rp.Name.ToUpper();
if (hashParameters.ContainsKey(rp.Name.ToUpper()))
{
if (hashParameters[rp.Name].ToString() != "")
rptParameters[intParam].Value = hashParameters[rp.Name].ToString();
else
rptParameters[intParam].Value = rp.DefaultValues[0].ToString();
}
intParam++;
}
********************************************************
The Hash table is filled as follows:
********************************************************
hashParameters = new Hashtable();
hashParameters.Add("OPCO", this.Opco);
hashParameters.Add("CONFIGTYPEGROUP", this.ConfigtypeGroup);
hashParameters.Add("CONFIGTYPE", this.ConfigType);
hashParameters.Add("ERRORCODE", "");
hashParameters.Add("VISITDATETIME_FROM", "");
hashParameters.Add("VISITDATETIME_TO", "");
hashParameters.Add("COUNTERNUMBER", "");
hashParameters.Add("ERRORDATETIME_FROM", "");
hashParameters.Add("ERRORDATETIME_TO", "");
hashParameters.Add("PARAMETERNUMBER", "");
hashParameters.Add("MODIFICATIONNR", "");
********************************************************
"Daniel Reib [MSFT]" wrote:
> If you want the server to use the current default values, then don't pass in
> anything for this values. Only pass in the three parameters that don't have
> defaults and the server will then use the current default value during
> rendering.
> --
> -Daniel
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> "Gert" <Gert@.discussions.microsoft.com> wrote in message
> news:66030BB4-9273-4AF1-B608-9B01F77ED7FD@.microsoft.com...
> > I already found the solution.
> > I have to write:
> > rptParameters[intParam].Value = rp.DefaultValues[0].ToString();
> > in stead of:
> > rptParameters[intParam].Value = rp.DefaultValues.ToString();
> >
> > This will give back the default value defined in the report
> >
> >
> > "Gert" wrote:
> >
> > > My report has 6 parameters. 3 Of them are defined with default values.
> How can I via the webservice method use these default values? I am building
> the parameters dynamically. You can see that the first 3 parameters are
> filled in depending on the value selected in a dropdown box. With the last 3
> I want to use the default values. Is this possible and how do I do this.
> When with the first 3 parameters, no value is selected in the dropdown box,
> the default values shouls also be used but this is not yet programmed. Can
> anyone help me with this?
> > >
> > > ReportParameter[] parameters = null;
> > >
> > > parameters = rs.GetReportParameters(reportPath, historyID, forRendering,
> reportHistoryParameters, credentials);
> > >
> > > ParameterValue[] rptParameters = new
> ParameterValue[parameters.GetLength(0)];
> > >
> > > int intParam = 0;
> > > foreach (ReportParameter rp in parameters)
> > > {
> > > rptParameters[intParam] = new ParameterValue();
> > > rptParameters[intParam].Name = rp.Name;
> > > switch(rp.Name.ToUpper())
> > > {
> > > case "OPCO":
> > > rptParameters[intParam].Value = this.Opco;
> > > break;
> > > case "CONFIGTYPEGROUP":
> > > rptParameters[intParam].Value = this.ConfigtypeGroup;
> > > break;
> > > case "CONFIGTYPE":
> > > rptParameters[intParam].Value = this.ConfigType;
> > > break;
> > > case "ERRORCODE":
> > > rptParameters[intParam].Value = rp.DefaultValues.ToString(); break;
> > > case "VISITDATETIME_FROM":
> > > rptParameters[intParam].Value = rp.DefaultValues.ToString())
> > > break;
> > > case "VISITDATETIME_TO":
> > > rptParameters[intParam].Value = rp.DefaultValues.ToString();
> > > break;
> > > }
> > >
> > > intParam++;
> > > }
> > >
> > > firstPage = rs.Render( reportPath,
> > > format,
> > > null,
> > > deviceInfo,
> > > rptParameters,
> > > null,
> > > null,
> > > out encoding,
> > > out mimeType,
> > > out reportHistoryParameters,
> > > out warnings,
> > > out streamIDs);
>
>|||Sure you could, just dynamically allocate an array and add to that array as
you find parameters the user has set. Then use the dynamic array to pass to
render. The only problem with your code would be if the default values
changed between your call to GetReportParameters and Render. In your code
you will use the old value. If you are displaying this value to the user,
then this is probably what you want. If you are displaying something like
'Use default' then the user may not get the actual default at render time.
--
-Daniel
This posting is provided "AS IS" with no warranties, and confers no rights.
"Gert" <Gert@.discussions.microsoft.com> wrote in message
news:C8CD66F1-CFB0-4A33-A90E-00919BB04B1B@.microsoft.com...
> I can't use your option because I have to loop through all the report
parameterss because I have different reports with different paramaters and I
don't know in the beginning of the program for which parameter the user will
select a value or not. If no value selected, the default value of the report
is retrieved.
> I use the following code and this works perfect. I use a Hash table(see
below) to store the paramaters and its values if they are selected.
> ********************************************************
> ReportParameter[] parameters = null;
> parameters = rs.GetReportParameters(reportPath, historyID, forRendering,
reportHistoryParameters, credentials);
> ParameterValue[] rptParameters = new
ParameterValue[parameters.GetLength(0)];
> int intParam = 0;
> foreach (ReportParameter rp in parameters)
> {
> rptParameters[intParam] = new ParameterValue();
> rptParameters[intParam].Name = rp.Name.ToUpper();
> if (hashParameters.ContainsKey(rp.Name.ToUpper()))
> {
> if (hashParameters[rp.Name].ToString() != "")
> rptParameters[intParam].Value =hashParameters[rp.Name].ToString();
> else
> rptParameters[intParam].Value = rp.DefaultValues[0].ToString();
> }
> intParam++;
> }
> ********************************************************
> The Hash table is filled as follows:
> ********************************************************
> hashParameters = new Hashtable();
> hashParameters.Add("OPCO", this.Opco);
> hashParameters.Add("CONFIGTYPEGROUP", this.ConfigtypeGroup);
> hashParameters.Add("CONFIGTYPE", this.ConfigType);
> hashParameters.Add("ERRORCODE", "");
> hashParameters.Add("VISITDATETIME_FROM", "");
> hashParameters.Add("VISITDATETIME_TO", "");
> hashParameters.Add("COUNTERNUMBER", "");
> hashParameters.Add("ERRORDATETIME_FROM", "");
> hashParameters.Add("ERRORDATETIME_TO", "");
> hashParameters.Add("PARAMETERNUMBER", "");
> hashParameters.Add("MODIFICATIONNR", "");
> ********************************************************
>
> "Daniel Reib [MSFT]" wrote:
> > If you want the server to use the current default values, then don't
pass in
> > anything for this values. Only pass in the three parameters that don't
have
> > defaults and the server will then use the current default value during
> > rendering.
> >
> > --
> > -Daniel
> > This posting is provided "AS IS" with no warranties, and confers no
rights.
> >
> >
> > "Gert" <Gert@.discussions.microsoft.com> wrote in message
> > news:66030BB4-9273-4AF1-B608-9B01F77ED7FD@.microsoft.com...
> > > I already found the solution.
> > > I have to write:
> > > rptParameters[intParam].Value = rp.DefaultValues[0].ToString();
> > > in stead of:
> > > rptParameters[intParam].Value = rp.DefaultValues.ToString();
> > >
> > > This will give back the default value defined in the report
> > >
> > >
> > > "Gert" wrote:
> > >
> > > > My report has 6 parameters. 3 Of them are defined with default
values.
> > How can I via the webservice method use these default values? I am
building
> > the parameters dynamically. You can see that the first 3 parameters are
> > filled in depending on the value selected in a dropdown box. With the
last 3
> > I want to use the default values. Is this possible and how do I do this.
> > When with the first 3 parameters, no value is selected in the dropdown
box,
> > the default values shouls also be used but this is not yet programmed.
Can
> > anyone help me with this?
> > > >
> > > > ReportParameter[] parameters = null;
> > > >
> > > > parameters = rs.GetReportParameters(reportPath, historyID,
forRendering,
> > reportHistoryParameters, credentials);
> > > >
> > > > ParameterValue[] rptParameters = new
> > ParameterValue[parameters.GetLength(0)];
> > > >
> > > > int intParam = 0;
> > > > foreach (ReportParameter rp in parameters)
> > > > {
> > > > rptParameters[intParam] = new ParameterValue();
> > > > rptParameters[intParam].Name = rp.Name;
> > > > switch(rp.Name.ToUpper())
> > > > {
> > > > case "OPCO":
> > > > rptParameters[intParam].Value = this.Opco;
> > > > break;
> > > > case "CONFIGTYPEGROUP":
> > > > rptParameters[intParam].Value = this.ConfigtypeGroup;
> > > > break;
> > > > case "CONFIGTYPE":
> > > > rptParameters[intParam].Value = this.ConfigType;
> > > > break;
> > > > case "ERRORCODE":
> > > > rptParameters[intParam].Value = rp.DefaultValues.ToString(); break;
> > > > case "VISITDATETIME_FROM":
> > > > rptParameters[intParam].Value = rp.DefaultValues.ToString())
> > > > break;
> > > > case "VISITDATETIME_TO":
> > > > rptParameters[intParam].Value = rp.DefaultValues.ToString();
> > > > break;
> > > > }
> > > >
> > > > intParam++;
> > > > }
> > > >
> > > > firstPage = rs.Render( reportPath,
> > > > format,
> > > > null,
> > > > deviceInfo,
> > > > rptParameters,
> > > > null,
> > > > null,
> > > > out encoding,
> > > > out mimeType,
> > > > out reportHistoryParameters,
> > > > out warnings,
> > > > out streamIDs);
> >
> >
> >