Writing A Custom Class

Nov 27, 2006

Hello everybody,

I am new to .NET programming and the C# language. I'm coming from a ColdFusion/Java background, but am trying to learn .NET to further my abilities as a programmer, and take advantage of the CLR functionality in SQL Server.

What I am wondering is: is it possible to write an assembly which has stored procedures and functions that each utilize a custom class written within that assembly?

I am having some trouble with this concept. I am writing a UDF that will compile various data together and build a string from it. To help simplify the code, I want to build a custom class which will represent the primary object I am running the compilations against.

I would like to have the class be able to load its data directly from the database using a load() method. However, I am getting the following error when trying to run the UDF:

Msg 6522, Level 16, State 2, Line 1
A .NET Framework error occurred during execution of user defined routine or aggregate 'CompileList':
System.Security.SecurityException: Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
System.Security.SecurityException:
at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.PermissionSet.Demand()
at System.Data.Common.DbConnectionOptions.DemandPermission()
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at vtrenz_listmanager_package.lib.iMAList.load()
at UserDefinedFunctions.CompileList(Int32 ownerid, Int32 userid, Int32 listid)

Any help and/or insight would be greatly appreciated.

Thanks,
JD

View 6 Replies


ADVERTISEMENT

Custom Class For Function

Mar 16, 2007

I have several fuctions that I would like to share between my different script tasks in my SSIS package. I assume I do this by creating a custom class, but I cant quite figure it out. Can someone please point me in the right direction?

Thank You!!

View 4 Replies View Related

Custom Assembly Class Not Defined

Jan 19, 2006

I have a custom assembly that i'm trying to get tied into my report. the problem is when i try to call it i get the error that the class is not defined

I have the class in the references tab and the class name and instance name both have a name.

here's the error I'm getting

Error 1 [rsCompilerErrorInClassInstanceDeclaration] Error in class instance declaration for class Assembly_1: [BC30002] Type '[ClassName]' is not defined. [Project folder][reportname].rdl 0 0

View 6 Replies View Related

OleDB Connection Class In Custom Task?

Jun 9, 2006

I have OLE DB Connections set up in my connection manager (Native OLE DBMicrosoft OLE DB Provider for SQL Server). I would like to reference and query these connections from a custom task, written in C#. I currently reference it as follows:

using System.Data.OleDb;

...................................

OleDbConnection connection = (OleDbConnection) connections["MyConnection"].AcquireConnection(null);

What may be obvious to some (though wasn't to me, as I am new at this), when I run the task, I get an error saying that I cannot make this cast. After perusing the boards, I understand that this is because I am not making a cast to the right connection type. Well, that is where I am lost. What connection type (and corresponding library) do I need to reference? I want to continue to use the "Native OLE DB..." connection.

Thanks!

View 3 Replies View Related

App.Config Files In A Custom Database Extension Class Library

Aug 15, 2006

Good Morning..

We're having a heck of a good time trying to implement our first CDE project in SSRS 2005.

In our SDE class library we have included an App.Config file where we want to store configuration settings..

Trouble is that when we view the configuration settings or connection string settings in debug mode, they're not being read for some reason..

Here's our app.config file:
-------------------------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>


<configuration>

<configSections>

</configSections>

<appSettings>

<add key="eventLogName" value="FocusDPEEventLog" />

</appSettings>

<connectionStrings>

<add name="PassConnString" connectionString="Data Source=SOMEDATASOURSE;Persist Security Info=True;User ID=SOMEUSERNAME;Password=SOMEPASSWORD;Unicode=True"

providerName="System.Data.OracleClient" />

</connectionStrings>

</configuration>

-------------------------------------------------------------
Here's what our Immediate window Debugger is tellin' us about our configuration settings:


-------------------------------------------------------------

ConfigurationManager.AppSettings

{System.Configuration.KeyValueInternalCollection}

[System.Configuration.KeyValueInternalCollection]: {System.Configuration.KeyValueInternalCollection}

base {System.Collections.Specialized.NameObjectCollectionBase}: {System.Configuration.KeyValueInternalCollection}

AllKeys: {Dimensions:[0]}<----incorrect should be 1

ConfigurationManager.ConnectionStrings

Count = 1 <----ok, is one, but the wrong 1, see 3 lines down...

base {System.Configuration.ConfigurationElementCollection}: Count = 1

ConfigurationManager.ConnectionStrings[0]

{data source=.SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true}<--Should be PassConnString

base {System.Configuration.ConfigurationElement}: {data source=.SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true}

ConnectionString: "data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"

Name: "LocalSqlServer"

ProviderName: "System.Data.SqlClient"

Now notice the stuff in bold...I have NO IDEA where this gosh-danged thing is reading, but it doesn't seem like it's the app.config file in our class library...

thanks..

Doug

View 1 Replies View Related

Class And Sequence Diagrams Describing SSIS Framework (for Custom Components)?

Jun 30, 2006

Hi,



Can anyone tell me where I might find the Class and Sequence Diagrams for the SSIS framework (for Custom Components)?



I've just started trying to create some Custom Transform Components and
I'm really struggling to get my head around the component lifecycle
(i.e what methods are called when, with what arguments, and why) with
just the BOL documentation to guide me.



Thanks in advance,



Lawrie

View 1 Replies View Related

Integration Services :: How To Execute Custom Class Library Code Through SSIS

Jun 11, 2015

I have a requirement in which i have to create a custom .net class library for Ex:-I retrieve password(s) from a thrid party component. Below is what i am doing.

(1) Created a custom class library which reads a custom .xml file from a drive Ex:- "D:MyAppMYAppCofig.xml" and sets to my properties of my custom class library and inside it i created an instance of third party component's class and passed these values. Since i need to use this .net custom class library both in web and ssis/database side i am using this custom .xml file.

(2) After validating passed data (properties set in custom .net class library) the thrid party component instance object created in my custom .net class libraty returs a password to me own custom .net class libray.

(3) This password I use in my web app for connecting to database. This code is working fine.

(4) My question is how to execute a custom .net class library code through ssis and to use the my same custom .net class library and pass the password to my SSIS component / taks so that that code block also uses the returned password to connect and do any needed tasks? In other words how to use custom .net class library from SSIS.

My Environment is as follows:-
SQL Server is : 2008 R2
VS.NET 2013

View 5 Replies View Related

Writing A Custom Code Example

Oct 19, 2007


I have been stuck in a problem for a while now. I am trying to count the number of groups. I tried soo many things and nothing worked . Now I want to try to write a function that does the counting for me.

Can somebody write me an example of a cutom code that can be called from expression.
So my custome code should be something like that

Public int CountFun(int counter)
{
Return counter= counter +1;

}

Also how do I call this method from my expression?
i am going to call it from a field inside the groups, so each time the group is implemented i add one to the counter.

thanks

View 4 Replies View Related

How Do I Declarative Bind To A Data Member Of A Custom Class Object Stored In The Session

Dec 1, 2006

I have a SqlDataSource that has a parameter that I am trying
to set.

 

 

The item is stored in a session field called “GameObject�

Game Object is a simple class that has a several variables.

I am trying to access the .name data member of the class.

 <asp:SessionParameter Name="GameCode" SessionField="((GamingSystem)Session[‘GameObject’]).Name" />  

This does not work. Is there a way to declarative bind to
the item that I am for.

 

View 3 Replies View Related

Need Help Writing A Custom View In Sql Server

Jan 23, 2007

Does anyone know
if the following sql view is possible to write and execute as a view script?

 



**********
find employee matching the given UserID*************     SELECT  * FROM Employees WHERE EmployeeID=@UserID

 

***********
find client matching the given ClientID**********     SELECT *
FROM Clients WHERE ClientID=@ClientID 





**********find
all contacts and events associated with ClientID*********      SELECT *
FROM Contacts WHERE Contact.ClientID=@ClientIDSELECT *
FROM Events WHERE Event.ClientID=@ClientID

 

*********select
all audits with Key values matching the primary keys of each client, contact or
event*********SELECT *
FROM Audit Where Key In (Client.ClientID, Contact.ContactID, Event.EventID)

 I basically
need to find a employee based on its ID.  Then I need to find any records from the table Audit
with Key values matching the given fields in the results of any clients, contacts events that were returned from the previous select statements.  Is this possible?

View 5 Replies View Related

Editing Tables & Writing Custom Stored Procedures

Feb 26, 2007

Hi all,

I’m currently writing a web application on student exam timetables, I’m using SQL Server 2005 as the back-end for the database.

At present, the case states that if a student is in one examination, he/she can’t attend, or be allocated another examination while the first examination is in place, which would result in a clash

The way I’m going to target this is by writing a stored procedure in SQL Server 2005 to return an error code, which I’ll translate using ASP,NET, however at present I’m having difficulty writing the SQL code. This is because…

I’m using SQL Server 2005 Management Studio; I created the tables using MS Access and upsized them using the wizard. I can now access my database, but having difficulty editing my tables and with code…

Any ideas??

Thank-you

View 2 Replies View Related

Enable Error Handling When Writing Custom Source Component /custom Error Handling Component.

Apr 21, 2006

1) We are writing a custome Source component for Oracle with OCI calls, Could some one please let me know how to Enable Error Handling for the Same,

2) Is it possible to write Custome Error Handeling Component for SSIS? if yes could you please help me on how to write it.

Thanks in advance.

View 1 Replies View Related

SqlDatareader Belongs To Which Class Is It Sealed Or Static Class?

Feb 21, 2008

Hai Guys,
       I have a doubt Regarding SqlDataReader
      i can able to create object to Sqlconnection,Sqlcomand etc...
     but i am unable to create object for SqlDataReader ?
     Logically i understand that SqldataReader a way of reading a forward-only stream of rows from a SQL Server database. This class cannot be inherited.
   sqlDatareader belongs to which class is it sealed or static class?
can we create own class like SqldataReader .......
Reply Me ...... if any one know the answer.............. 
 

View 8 Replies View Related

Can SqlDataSource Class Inherite To Another Class

Feb 1, 2008

Does any one inherit SqlDatasource class?
I treid it as :
public class MYDataSource : System.Web.UI.WebControls.SqlDataSource
{public MYDataSource(){
 
}
 
}
Debugger dont give any error or warning when i buld project. But when i use it in a page Visual studio is crashed.
 Can any one help me ?

View 1 Replies View Related

Displaying Custom Properties For Custom Transformation In Custom UI

Mar 8, 2007

Hi,

I am creating a custom transformation component, and a custom user interface for that component.

In
my custom UI, I want to show the custom properties, and allow users to
edit these properties similar to how the advanced editor shows the
properties.

I know in my UI I need to create a "Property Grid".
In
the properties of this grid, I can select the object I want to display
data for, however, the only objects that appear are the objects that I
have already created within this UI, and not the actual component
object with the custom properties.

How do I go about getting the properties for my transformation component listed in this property grid?

I am writing in C#.

View 5 Replies View Related

Expression Editor On Custom Properties On Custom Data Flow Component

Aug 14, 2007

Hi,

I've created a Custom Data Flow Component and added some Custom Properties.

I want the user to set the contents using an expression. I did some research and come up with the folowing:





Code Snippet
IDTSCustomProperty90 SourceTableProperty = ComponentMetaData.CustomPropertyCollection.New();
SourceTableProperty.ExpressionType = DTSCustomPropertyExpressionType.CPET_NOTIFY;
SourceTableProperty.Name = "SourceTable";






But it doesn't work, if I enter @[System:ackageName] in the field. It comes out "@[System:ackageName]" instead of the actual package name.

I'm also unable to find how I can tell the designer to show the Expression editor. I would like to see the elipses (...) next to my field.

Any help would be greatly appreciated!

Thank you

View 6 Replies View Related

Expression Issue With Custom Data Flow Component And Custom Property

Apr 2, 2007

Hi,



I'm trying to enable Expression for a custom property in my custom data flow component.

Here is the code I wrote to declare the custom property:



public override void ProvideComponentProperties()

{


ComponentMetaData.RuntimeConnectionCollection.RemoveAll();

RemoveAllInputsOutputsAndCustomProperties();



IDTSCustomProperty90 prop = ComponentMetaData.CustomPropertyCollection.New();

prop.Name = "MyProperty";

prop.Description = "My property description";

prop.Value = string.Empty;

prop.ExpressionType = DTSCustomPropertyExpressionType.CPET_NOTIFY;



...

}



In design mode, I can assign an expression to my custom property, but it get evaluated in design mode and not in runtime

Here is my expression (a file name based on a date contained in a user variable):



"DB" + (DT_WSTR, 4)YEAR( @[User::varCurrentDate] ) + RIGHT( "0" + (DT_WSTR, 2)MONTH( @[User::varCurrentDate] ), 2 ) + "\" + (DT_WSTR, 4)YEAR( @[User::varCurrentDate] ) + RIGHT( "0" + (DT_WSTR, 2)MONTH( @[User::varCurrentDate] ), 2 ) + ".VER"



@[User::varCurrentDate] is a DateTime variable and is assign to 0 at design time

So the expression is evaluated as: "DB189912189912.VER".



My package contains 2 data flow.

At runtime,

The first one is responsible to set a valid date in @[User::varCurrentDate] variable. (the date is 2007-01-15)

The second one contains my custom data flow component with my custom property that was set to an expression at design time



When my component get executed, my custom property value is still "DB189912189912.VER" and I expected "DB200701200701.VER"



Any idea ?



View 5 Replies View Related

Adding Custom Property To Custom Component

Aug 17, 2005

What I want to accomplish is that at design time the designer can enter a value for some custom property on my custom task and that this value is accessed at executing time.

View 10 Replies View Related

Custom Task - Custom Property Expression

Aug 16, 2006

I am writing a custom task that has some custom properties. I would like to parameterize these properties i.e. read from a varaible, so I can change these variables from a config file during runtime.

I read the documentation and it says if we set the ExpressionType to CPET_NOTIFY, it should work, but it does not seem to work. Not sure if I am missing anything. Can someone please help me?

This is what I did in the custom task

customProperty.ExpressionType = DTSCustomPropertyExpressionType.CPET_NOTIFY;

In the Editor of my custom task, under custom properties section, I expected a button with 3 dots, to click & pop-up so we can specify the expression or at least so it evaluates the variables if we give @[User::VaraibleName]

Any help on this will be very much appreciated.

Thanks

View 3 Replies View Related

SQL 2K5 Class

Oct 6, 2006

Does anybody know of a good facility to take a SQL 2000 to SQL 2005 Admin course that is geared towards experienced DBAs, that is not so costly. I'm not the type that can sit and read on my own to learn, it has to be a real project or a classroom environment.

Also, the NYC area.

thanks,
Paul

View 1 Replies View Related

SQL Class

May 8, 2008

Just started SQL Class and I am struggling with an assignment.
Would someone be kind to give me some help please?

your task is to make a stored procedure that will only billcustomers making monthly payments higher than $500.A Customer can have multiple Plans (services for which they pay amonthly fee).

You have to execute a billing procedure for each single active planunder an eligible customer account. Eligible customer account is anaccount that makes estimated monthly payment higher than $500.

You are given 2 tables, "Customers" and "Plans". Table "Customers" has columns: CustomerID, EmailAddressTable "Plans" has columns: PlanID, CustomerID, MonthlyPrice, isClosed,NextBillDate

Also, you are given two stored procedures named "Bill_Plan" and"Send_Email". All stored procedures returns 0 upon success and negativenumber upon failure.The "Bill_Plan" actually bills a customer for a plan. The storedprocedure takes one input parameter and have one output parameter.

Bill_Plan
@nPlanID = @PlanID,
@dtNewBillDate = @NextBillDate output

You have to use the output parameter @NextBillDate to updatePlans.NextBillDate with its new value.

Upon successful billing you have to send en email to the customer'semail address. The "Send_Email" stored procedure takes two inputparameters.
Send_Email
@sEmailAddress = @EmailAddress,
@sSubject = 'Your Invoice is Ready'
You have to rollback any single billing transaction upon any kind offailure and continue billing the remaining plans. (Important!!!)


Thank signed I don't want to flunk!

View 6 Replies View Related

Save Class

Feb 27, 2007

Hello,I created a class in my .Net code and I have an SQL 2005 table with a column of type image (I suppose I should use this type)After I define the class properties I need create a new record and save the class in the database.Can I do it the same way as I would save, for example, a string in a varchar field?Thanks,Miguel 

View 1 Replies View Related

Calling A SP In A Class

Jan 17, 2008

Hello,
I have the class below. And trying to execute it on a button click event.
What am i doing wrong ?
Thanks
Here is the button click event1 protected void Button1_Click(object sender, EventArgs e)
2 {
3 signup_data_entry signup = new signup_data_entry();
4 signup.signup_data_entry();
5
6 }

  
Here is my class file. please advice
 1 public class signup_data_entry
2 {
3 public signup_data_entry()
4 {
5 //SqlConnection con = new SqlConnection("cellulant_ConnectionString");
6 SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["cellulant_ConnectionString"]);
7
8 SqlCommand command = new SqlCommand("Cellulant_Users_registration", con);
9 command.CommandType = CommandType.StoredProcedure;
10
11 con.Open();
12
13 //string IP = new string();
14
15
16 command.Parameters.Add(new SqlParameter("@RegionID", SqlDbType.Int, 0, "RegionID"));
17 command.Parameters.Add(new SqlParameter("@RegionDescription", SqlDbType.NChar, 50, "RegionDescription"));
18
19 command.Parameters[0].Value = 4;
20 command.Parameters[1].Value = "SouthEast";
21
22 int i = command.ExecuteNonQuery();
23
24
25 }
26 }

 

View 6 Replies View Related

How To Make Class

Jan 25, 2008

hiiiiiiiiii    I am creating a web application using vb.net  in which i m using the concept of classes. now i am done all the code for inserting the values in the database using the class but it is difficult to fetch the values from the database using select command and sending them to a WebForm  . i want to know how i send send the values coming from the select command to a datagrid or another web controlif possible provide me a sample code  thanks for your help

View 2 Replies View Related

Class Not Registered

Dec 28, 2001

Not able to use Enterprise Mgr after updgrade. Getting Class not registered? Any idea what to do to correct? Thanks, A

View 1 Replies View Related

Book And Class

Jul 23, 2005

Can anyone recommend a good SQL Server book or class forBeginner-Intermediate, please?Thanks

View 2 Replies View Related

Class Lifetime

Feb 4, 2008



there was a post some time ago but nobody answered. Maybe somebosy will answer now?



I have created a class which contains a few UDF's. The class has a static constructor that reads from the databse and loads a Dictionary<> collection.

What is the lifetime of the class?
What will cause the static constructor to be called again?
When will it be garbage collected?
If the life time is limited by default, can it be extended?

Thanks.

View 2 Replies View Related

Xml/c# Class Definition

May 30, 2007

Good morning, all!

I'm tasked with creating POCO (C# Class Object) and XML definitions for three different kinds of records coming from my input file. The problem is that I'm not sure how to do this within the SSIS framework. It seems to me that I can somehow define a class and include XML element tags in the definition, but I'm not sure where to look/who to ask/how to do that!

The goal is to be able to assign the data types and class attributes for various parts of each input record based on position, and to serialize the data as XML (and therefore my inputs to my Data Flow will be XML objects instead of a flat file, as I had been doing it...).

Can anyone point me at a good tutorial? Or a simple example?

Also, is "DateTime" a recognized data type in C#?

Thanks a bunch!

Jim Work

View 6 Replies View Related

Class Not Registered

Feb 14, 2007

Hi,

when i am trying to open a table from Microsoft Visua Studio 2005
I got the following error

Class Not Registered.Loking for object with classID:......

how resolve this?????

View 1 Replies View Related

Looking For Lab Files From Class

May 29, 2007

I recently took a class on SQL 2005. The classwork had lab files but I did not manage to hang on to the files. Are those files available for DL from MS?

I am specifically looking for the files from Module 7 "Planning for Source Control, Unit Testing, and Deployment"



TIA

View 1 Replies View Related

ReportingService2005 Class

Nov 14, 2007

Hi, I'm having trouble with the ReportingService2005 object

I'm trying to use the Get and SetPolicies methods and have used ideas from other snippets in order to get this:

...
Microsoft.SqlServer.ReportingServices2005.ReportingService2005 RS = new Microsoft.SqlServer.ReportingServices2005.ReportingService2005();


RS.Credentials = System.Net.CredentialCache.DefaultCredentials;

RS.Url = http://www.MyServer.co.uk/ReportServer/ReportService2005.asmx;


bool ip;

Policies = RS.GetPolicies("/", out ip);




RS.SetPolicies("/", Policies);

...

Does anyone have any experience with this object, or any working examples, I suspect I'm still missing some permissions thing but at the moment all I get is this annoyingly unhelpful message:

Client found response content type of 'text/html; charset=utf-8', but expected 'text/xml'. The request failed with the error message: --





BODY
{font-family:Verdana;font-weight:normal;font-size:8pt;color:black;}
H1
{font-family:Verdana;font-weight:700;font-size:15pt;}
LI
{font-family:Verdana;font-weight:normal;font-size:8pt;display:inline;}
.ProductInfo
{font-family:Verdana;font-weight:bold;font-size:8pt;color:gray;}
A:link
{font-size:8pt;font-family:Verdana;color:#3366CC;text-decoration:none;}
A:hover
{font-size:8pt;font-family:Verdana;color:#FF3300;text-decoration:underline;}
A:visited
{font-size:8pt;font-family:Verdana;color:#3366CC;text-decoration:none;}


Reporting Services Error



An internal error occurred on the report server. See the error log for more details. (rsInternalError) Get Online Help

For more information about this error navigate to the report server on the local server machine, or enable remote errors

SQL Server Reporting Services
--.


Thanks for your help,

Sean.

View 2 Replies View Related

TableAdapter Class Not Generated

Aug 2, 2006

I created a new DataSet object using the
wizard and had no probs, it's very straightforward.  I created a
GetProducts() method and also added a GetProductCount() method.  I
read somewhere that when the DataSet is saved, it will generate the
TableAdapter classes and store them in the project nested under the
DataSet object.  This isn't happening, the files aren't there and
yes I'm displaying all files.  There *is* however the TableAdapter
class but it's in not in the project, it's a temporary file w/ the
following path:
   
C:WINDOWSMicrosoft.NETFrameworkv2.0.50727Temporary ASP.NET
Fileswebsitef38f8b5500014aeSources_App_Codepw_products.xsd.72cecc2a.cs.

I saved the DataSet several times, compiled the entire solution and
even closed the solution yet this temporary file isn't getting saved
where it should be.  Does anyone have any ideas abt this? 
I'm eager to start developing my DAL and def want to use these
TableAdapter classes.

Thx in advance,
-Pete

View 2 Replies View Related

Invalid Class String

Jun 8, 2007

Hi,
I'm working on both VWDEE and VBEE and, in each, when I try to add a database diagram I get the following message (after the 'Do you want to create required objects' prompt) 'Invalid Class String'.
Any ideas?

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved