Showing posts with label dll. Show all posts
Showing posts with label dll. Show all posts

Friday, March 23, 2012

Passing DataSet's into Custom Code

Is it possible to send a DataSet to a Custom code from the report. I am
planning to use .net dll's in my report as a custom code.
ThanksIf you mean an RS dataset you can't because RS datasets are not exposed
programatically. Some workarounds you may consider:
1. Retrieve an ADO.NET dataset in your code using the same query. In other
words, clone the dataset.
2. If the report has a matrix region, you can redirect the matrix region to
read its values from an embedded function. In this way you can populate a
custom data structure, e.g. an Array or an ADO.NET dataset, which you can
pass the external assembly. As a practical example, you may want to look at
my report sample "Sales by Product Category" which collects the matrix
region data in an array and sends it off to an external assembly to get
forecasted sales.
http://www.manning-sandbox.com/thread.jspa?threadID=10383&tstart=0
Hope this helps.
---
Teo Lachev, MCSD, MCT
Author: "Microsoft Reporting Services in Action"
http://www.prologika.com
"aplearner" <aplearner@.discussions.microsoft.com> wrote in message
news:0DC175E9-0ECE-47D1-A266-EA39E238F998@.microsoft.com...
> Is it possible to send a DataSet to a Custom code from the report. I am
> planning to use .net dll's in my report as a custom code.
> Thanks|||What are you trying to accomplish? If you want to calculate additional columns based on data in
previous columns within the same row, look into calculated fields. If you want more control over
the dataset manipulation, you can write your own Data Processing Extension which reads in the
dataset and performs whatever logic you want to do on it prior to submitting the data to the report.
--
Thanks.
Donovan R. Smith
Software Test Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
"aplearner" <aplearner@.discussions.microsoft.com> wrote in message
news:0DC175E9-0ECE-47D1-A266-EA39E238F998@.microsoft.com...
> Is it possible to send a DataSet to a Custom code from the report. I am
> planning to use .net dll's in my report as a custom code.
> Thanks|||For creating your own DPE, start by searching Google Groups [1]. I know there are a few samples out
there.
Without writing a DPE, if you have a dataset with two columns returned (Quantity and Price) and you
need a third column computed (Total), you can either add a column to your table with this
expression:
=Fields!Quantity.Value * Fields!Price.Value
or you can right-click in the Fields window in Report Designer and choose Add Field. You can create
a new computed field named Total and tell it to always have a value equal to the above expression.
To sort, you should attempt to sort the data in the database prior to being sent to the report. If
that isn't possible, look in our Books Online for more information on how to Sort rows shown in
tables.
[1]
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&group=microsoft.public.sqlserver.reportingsvcs
--
Thanks.
Donovan R. Smith
Software Test Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
"aplearner" <aplearner@.discussions.microsoft.com> wrote in message
news:995C993F-D0CE-4224-8F25-29EFE1E555F3@.microsoft.com...
> Donovan
> I have two ques,
> Ques1:
> Can you explain me how to do this[you can write your own Data Processing
> Extension]. My situation is, my dataset would return 6 rows. Before display
> these rows in my report using table, i have to assign one of the column
> values in 6 text boxes.
> Ques2:
> Is it possible to suffle/sort my dataset by perticluar column value[s] prior
> to submitting the data to the report ?
> Thanks in advance
>
> "Donovan R. Smith [MSFT]" wrote:
> > What are you trying to accomplish? If you want to calculate additional columns based on data in
> > previous columns within the same row, look into calculated fields. If you want more control
over
> > the dataset manipulation, you can write your own Data Processing Extension which reads in the
> > dataset and performs whatever logic you want to do on it prior to submitting the data to the
report.
> >
> > --
> > Thanks.
> >
> > Donovan R. Smith
> > Software Test Lead
> >
> > This posting is provided "AS IS" with no warranties, and confers no rights.
> >
> > "aplearner" <aplearner@.discussions.microsoft.com> wrote in message
> > news:0DC175E9-0ECE-47D1-A266-EA39E238F998@.microsoft.com...
> > > Is it possible to send a DataSet to a Custom code from the report. I am
> > > planning to use .net dll's in my report as a custom code.
> > >
> > > Thanks
> >
> >
> >sql

Wednesday, March 21, 2012

Passing by reference an ADO Connection from Excel VBA to C++

I want to pass by reference an ADO Connection which has been already opened in Excel VBA to a C++ DLL, but I get the following error:

"Unhandled exception at 0x4dd5230f in EXCEL.EXE: 0xC0000005: Access violation writing location 0x1775238d."

What am I doing wrong?

The code I am using is:

- VBA:

Declare Function Retrieve_C Lib "xxx.dll" (ByRef conn As ADODB.Connection) As Double
Function Test() As Double
Dim c As ADODB.Connection
Set c = New ADODB.Connection
c.Open "Provider=MSDASQL; Data Source=xxx"
Test = Retrieve_C(c)
End Function

- C++:

#import "xxx\msado15.dll" rename("EOF","ADOEOF")
double __stdcall Retrieve_C(ADODB::_ConnectionPtr conn)
{
CoInitialize(NULL);
ADODB::_RecordsetPtr recordset(__uuidof(ADODB::Recordset));
recordset->Open("SELECT xxx",
conn.GetInterfacePtr(),
ADODB::adOpenForwardOnly,
ADODB::adLockReadOnly,
ADODB::adCmdText);
return recordset->Fields->GetItem("xxx")->GetValue();
recordset->Close();
}

I have moved this thread to the native data access forum. You are more likely to get a response there, since this is native ADO and not ADO.NET.

http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=87&SiteID=1

Thanks,

Sarah

|||

Try using "xxx.dll" (ByVal conn As ADODB.Connection) instead.

(Passing conn ByVal instead of ByRef)

Also as a side note, you've placed call to recordset close method after the return statement...


This posting is provided "AS IS" with no warranties, and confers no rights.

sql

Monday, February 20, 2012

Pasing parameter-value to method in .dll

Hello,
I have a class in a .dll wich I instantiate in reporting services on
the References tab. The instance is called "Myinstance". I also have a
parameter called "parm1".
>From custom code I have:
Protected Overrides Sub OnInit()
MyInstance.company(Parameters!parm1.value)
End Sub
The method company is declared "public void company(string _company)".
My problem is, that I get the error:
"... The definition of the report "/MyReport" is invalid. There is an
error on line 1 of custom code: [BC30469] Reference to a non-shared
member requires an object reference."
If, in custom code, I hard-code the parameter to the method company
instead of trying to get it from a parameter, it works, so it look as
if I try to access the parameter-value before the parameter is
available or I'm accessing the parameter in a wrong way.
I need to pass the value of the parameter "parm1" to a method
"company(string _company)" before the report is build, as fields in
the report will call other functions in the .dll and what they return
depends on the value of "parm1" passed to the method "company".
So, any suggestion? What am I doing wrong?
Thanks in advance
/PeterHey Peter.
Add a variable to your assembly call such as:
Protected Overrides Sub OnInit(parm1 as string)
MyInstance.company(Parameters!parm1.value)
End Sub
Then call you custom code like:
=code.oninit(parameters!parm1.value)
Michael
"Peter" wrote:
> Hello,
> I have a class in a .dll wich I instantiate in reporting services on
> the References tab. The instance is called "Myinstance". I also have a
> parameter called "parm1".
> >From custom code I have:
> Protected Overrides Sub OnInit()
> MyInstance.company(Parameters!parm1.value)
> End Sub
> The method company is declared "public void company(string _company)".
> My problem is, that I get the error:
> "... The definition of the report "/MyReport" is invalid. There is an
> error on line 1 of custom code: [BC30469] Reference to a non-shared
> member requires an object reference."
> If, in custom code, I hard-code the parameter to the method company
> instead of trying to get it from a parameter, it works, so it look as
> if I try to access the parameter-value before the parameter is
> available or I'm accessing the parameter in a wrong way.
> I need to pass the value of the parameter "parm1" to a method
> "company(string _company)" before the report is build, as fields in
> the report will call other functions in the .dll and what they return
> depends on the value of "parm1" passed to the method "company".
> So, any suggestion? What am I doing wrong?
> Thanks in advance
> /Peter
>|||Oops one small change
"Michael C" wrote:
Protected Overrides Sub OnInit(parm1 as string)
MyInstance.company(parm1)
End Sub
Michael
> Hey Peter.
> Add a variable to your assembly call such as:
> Protected Overrides Sub OnInit(parm1 as string)
> MyInstance.company(Parameters!parm1.value)
> End Sub
> Then call you custom code like:
> =code.oninit(parameters!parm1.value)
> Michael
> "Peter" wrote:
> > Hello,
> >
> > I have a class in a .dll wich I instantiate in reporting services on
> > the References tab. The instance is called "Myinstance". I also have a
> > parameter called "parm1".
> >
> > >From custom code I have:
> >
> > Protected Overrides Sub OnInit()
> > MyInstance.company(Parameters!parm1.value)
> > End Sub
> >
> > The method company is declared "public void company(string _company)".
> >
> > My problem is, that I get the error:
> >
> > "... The definition of the report "/MyReport" is invalid. There is an
> > error on line 1 of custom code: [BC30469] Reference to a non-shared
> > member requires an object reference."
> >
> > If, in custom code, I hard-code the parameter to the method company
> > instead of trying to get it from a parameter, it works, so it look as
> > if I try to access the parameter-value before the parameter is
> > available or I'm accessing the parameter in a wrong way.
> >
> > I need to pass the value of the parameter "parm1" to a method
> > "company(string _company)" before the report is build, as fields in
> > the report will call other functions in the .dll and what they return
> > depends on the value of "parm1" passed to the method "company".
> >
> > So, any suggestion? What am I doing wrong?
> >
> > Thanks in advance
> > /Peter
> >
> >|||On 19 Jul., 18:20, Michael C <Micha...@.discussions.microsoft.com>
wrote:
> Oops one small change
> "Michael C" wrote:
> Protected Overrides Sub OnInit(parm1 as string)
> MyInstance.company(parm1)
> End Sub
> Michael
>
> > Hey Peter.
> > Add a variable to your assembly call such as:
> > Protected Overrides Sub OnInit(parm1 as string)
> > MyInstance.company(Parameters!parm1.value)
> > End Sub
> > Then call you custom code like:
> > =code.oninit(parameters!parm1.value)
> > Michael
> > "Peter" wrote:
> > > Hello,
> > > I have a class in a .dll wich I instantiate in reporting services on
> > > the References tab. The instance is called "Myinstance". I also have a
> > > parameter called "parm1".
> > > >From custom code I have:
> > > Protected Overrides Sub OnInit()
> > > MyInstance.company(Parameters!parm1.value)
> > > End Sub
> > > The method company is declared "public void company(string _company)".
> > > My problem is, that I get the error:
> > > "... The definition of the report "/MyReport" is invalid. There is an
> > > error on line 1 of custom code: [BC30469] Reference to a non-shared
> > > member requires an object reference."
> > > If, in custom code, I hard-code the parameter to the method company
> > > instead of trying to get it from a parameter, it works, so it look as
> > > if I try to access the parameter-value before the parameter is
> > > available or I'm accessing the parameter in a wrong way.
> > > I need to pass the value of the parameter "parm1" to a method
> > > "company(string _company)" before the report is build, as fields in
> > > the report will call other functions in the .dll and what they return
> > > depends on the value of "parm1" passed to the method "company".
> > > So, any suggestion? What am I doing wrong?
> > > Thanks in advance
> > > /Peter
Hello Michael,
Thanks for your reply.
There are two issues:
1) I forgot to mention, that pam1 gets its values from a query, so I
cannot call my custom code as "=code.oninit(parameters!parm1.value)"
2) When I tried the custom code in your message, I got this error:
"... There is an error on line 0 of custom code: [BC30284] sub
'OnInit' cannot be declared 'Overrides' because it does not override a
sub in a base class."
What should I do from here ?
Thanks
/Peter|||hey Peter,
Well ...
1) The "Parmameter!Parm1.Value" could be "Fields!MyField.value", or if it is
not generated from the dataset that drives the report (i.e. a secondary
query) then you can use First(Fields!MyField.Value,"MyParmQuery")
2) I haven't worked with Overrides, are you required to have 'Protected
Overrides' in the call, or can you simply state Protected Sub
OnInit(strParm1) or even Public Sub OnInit?
Michael
"Peter" wrote:
> On 19 Jul., 18:20, Michael C <Micha...@.discussions.microsoft.com>
> wrote:
> > Oops one small change
> >
> > "Michael C" wrote:
> >
> > Protected Overrides Sub OnInit(parm1 as string)
> > MyInstance.company(parm1)
> > End Sub
> >
> > Michael
> >
> >
> >
> > > Hey Peter.
> >
> > > Add a variable to your assembly call such as:
> >
> > > Protected Overrides Sub OnInit(parm1 as string)
> > > MyInstance.company(Parameters!parm1.value)
> > > End Sub
> >
> > > Then call you custom code like:
> >
> > > =code.oninit(parameters!parm1.value)
> >
> > > Michael
> >
> > > "Peter" wrote:
> >
> > > > Hello,
> >
> > > > I have a class in a .dll wich I instantiate in reporting services on
> > > > the References tab. The instance is called "Myinstance". I also have a
> > > > parameter called "parm1".
> >
> > > > >From custom code I have:
> >
> > > > Protected Overrides Sub OnInit()
> > > > MyInstance.company(Parameters!parm1.value)
> > > > End Sub
> >
> > > > The method company is declared "public void company(string _company)".
> >
> > > > My problem is, that I get the error:
> >
> > > > "... The definition of the report "/MyReport" is invalid. There is an
> > > > error on line 1 of custom code: [BC30469] Reference to a non-shared
> > > > member requires an object reference."
> >
> > > > If, in custom code, I hard-code the parameter to the method company
> > > > instead of trying to get it from a parameter, it works, so it look as
> > > > if I try to access the parameter-value before the parameter is
> > > > available or I'm accessing the parameter in a wrong way.
> >
> > > > I need to pass the value of the parameter "parm1" to a method
> > > > "company(string _company)" before the report is build, as fields in
> > > > the report will call other functions in the .dll and what they return
> > > > depends on the value of "parm1" passed to the method "company".
> >
> > > > So, any suggestion? What am I doing wrong?
> >
> > > > Thanks in advance
> > > > /Peter
> Hello Michael,
> Thanks for your reply.
> There are two issues:
> 1) I forgot to mention, that pam1 gets its values from a query, so I
> cannot call my custom code as "=code.oninit(parameters!parm1.value)"
> 2) When I tried the custom code in your message, I got this error:
> "... There is an error on line 0 of custom code: [BC30284] sub
> 'OnInit' cannot be declared 'Overrides' because it does not override a
> sub in a base class."
> What should I do from here ?
> Thanks
> /Peter
>|||On 20 Jul., 18:56, Michael C <Micha...@.discussions.microsoft.com>
wrote:
> hey Peter,
> Well ...
> 1) The "Parmameter!Parm1.Value" could be "Fields!MyField.value", or if it is
> not generated from the dataset that drives the report (i.e. a secondary
> query) then you can use First(Fields!MyField.Value,"MyParmQuery")
> 2) I haven't worked with Overrides, are you required to have 'Protected
> Overrides' in the call, or can you simply state Protected Sub
> OnInit(strParm1) or even Public Sub OnInit?
> Michael
Thanks again Michael,
I have to declared it 'Protected' otherwise it will complain that I
use a different access level.
If I declared it Protected Overrides Sub OnInit(DataArea As String),
that is, with one parameter, I get the error:
sub 'OnInit' cannot be declared 'Overrides' because it does not
override a sub in a base class.
If I declare it without any parameters as Protected Overrides Sub
OnInit(), I get the error
Reference to a non-shared member requires an object reference
If I declare it without 'Overrides' (with and without a parameter) I
get the error
Reference to a non-shared member requires an object reference
So I'm stuck again. I need to use a function that is executed before
the report is generated. I need it to call a method i my .dll with an
argument which is based on a selection from a parameter which in turn
is based on a dataset.
What should I try from here?
Thanks
/Peter