Accessing .NET Dlls From Stored Procedures
Oct 28, 2004Can anyone tell me is it possible to register and access .NET dlls from Stored procedures
and how to call those methods in those dlls from Stored procedures
Can anyone tell me is it possible to register and access .NET dlls from Stored procedures
and how to call those methods in those dlls from Stored procedures
I'm just wondering what the effect of including a form in a dll would have on a system? I created a dll that actually has a hidden form in it and is called from a stored procedure using SQL Server 2000. I needed some of the functionality of the richTextBox control, only I didn't want to actually display the form with the box on it. This seems to work when called from a stored procedure (the method called returns correct values and the form never shows up on the server), but are there any inherent problems with this I'm not aware of? I wouldn't think it would be a memory leak and we're not too worried about security. I'm using this as a shortcut around having to write something that converts rich text into plain text and allows us to search the document for keywords. I know this might be a ghetto way around it, but it seems to work.
View 2 Replies View RelatedHi,I was just wondering if it's possible to access views from stored procedures? I know it doesn't make much sense, but would it be possible? If so, can you also give me some code example?Thanks.
View 4 Replies View RelatedI have several hosted websites using MS SQL Server 2005 and ASP.NET 2.0 set up as DotNetNuke portals. I need to do a minor patch in a stored procedure to fix buggy functionality in one module. I have the patch, but what do I need to install on my local machine in order to edit the stored procedures on the hosted database?
The hosting company's support said to install SQL Server Management Services (SSMSEE.msi), but the install fails giving a link to a pre-requisite component called ADOMD.msi. That one seems to install okay, but I still get the same error when trying to install the Management program.
Perhaps I need SQL Server Express on my local machine? I'm really just looking for the best way to access and edit stored procedures on my hosted database?
I would REALLY appreciate a nudge in the right direction...?
Thanks.
Michael E. Smith
Hello,
What permissions do I need to set on our new SQL Server 2005 test server so that I can see the stored procedures, views and tables from Visual Studio development environment.
Example, I can see my older SQL Server 7 tables, edit them, write stored procedures, and so on. But while I can see the SQL Server 2005 and its databases, the folder underneath are empty and I cannot right-click to create New stored procedure or table.
My guess is that there is security involved, if so, what do I set on the new server?
If I'm wrong, and it's something else entirely, please advise.
Thanks!
I want to know the differences between SQL Server 2000 storedprocedures and oracle stored procedures? Do they have differentsyntax? The concept should be the same that the stored proceduresexecute in the database server with better performance?Please advise good references for Oracle stored procedures also.thanks!!
View 11 Replies View RelatedHi,
This Might be a really simple thing, however we have just installed SQL server 2005 on a new server, and are having difficulties with the set up of the Store Procedures. Every time we try to modify an existing stored procedure it attempts to save it as an SQL file, unlike in 2000 where it saved it as part of the database itself.
Thank you in advance for any help on this matter
Using SQL 2005, SP2. All of a sudden, whenever I create any stored procedures in the master database, they get created as system stored procedures. Doesn't matter what I name them, and what they do.
For example, even this simple little guy:
CREATE PROCEDURE BOB
AS
PRINT 'BOB'
GO
Gets created as a system stored procedure.
Any ideas what would cause that and/or how to fix it?
Thanks,
Jason
I require Api call or any ways to find the installed path of SQL SERVER 2005.
This is required becauses you application register set of extended procedures. As part of SQL SERVER 2005 we found that the dll has to be registered with full path in general
<b> "c:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLBinn" </b>
since customers may install the server in any drive , i require to find the installed path.
A help on this will help me a lot..
Thanks
Ilanthendral.R
Hi Group !!
I`m developing a web site with many grids, these grids obtains the data from a SQL Server 2005 DB which data is stored in XML Format... many times when the page load is done, this message appears :
File or assembly name Microsoft.Data.SqlXml, or one of its dependencies, was not found.
But when I access a second time to the same page, the data is displayed normally..
Why this could be happening???
Thanks
DiegoG
Is there a way to use a custom component programmatically (I'm using C# to create and run my packages) without installing a compiled .dll of the class into the SQL folders and the GAC? For instance, can I instantiate my custom component and somehow pass it to be used in a task in my code.
View 1 Replies View RelatedIn attempting to perform a "typical desktop" install to an NT 4.0 workstation,
install fails to register about 10 DLLs.
i.e. dtspkg.dll, dtspump.dll, msrpjt40.dll, dbscan.dll
As best as I know, the msrpjt40.dll already existed and had a version date of
11-11-98 9:51 P.M.
While the SQLSTP.LOG shows me they failed to register, I don't know why
they failed to register.
Any ideas, comments, etc. would be appreciated.
Thanks!!
I am developing a Script Task for my SSIS package to transfer a file via FTP over SSH (SFTP). I have a nice set of Assemblies/DLLs (purchased from IP*Works) that gives me the added functionality of SSH.
To even get Visual Studio for Applications to see it in the reference list, I copied the DLL (nsoftware.IPWorksSSH.Sftp.dll) to the C:WINDOWSMicrosoft.NETFrameworkv2.0.50727 directory, added it in the references for the script, and added the Imports nsoftware.IPWorksSSH.Sftp line in the script.
As described in: http://sqljunkies.com/WebLog/knight_reign/archive/2005/07/07/16018.aspx
Yet, when I try to run the SSIS package I get a DTS Script Task Runtime Error:
Could not load file or assembly 'nsoftware.IPWorksSSH.Sftp, Version=7.1.2203.0, Culture=neutral, PublicKeyToken=cdc168f89cffe9cf' or one of its dependencies. The system cannot find the file specified.
I tried to move the DLL to the bin directory in the SSIS Package, but that did not help.
Any Ideas?
Thank you for your time,
-Tim
Hi,
I am developing a native C++ application using SQLCE (.NET is not a current option). Am having a problem while using multiple accessors for multiple blobs in a table. After I read the data for the first blob & try to read the data for the second one, I get an error in one of the dlls (something about using heap data that was freed). Where can I get symbol data so that I can use something like Windbg to resolve my problem.
I've been having an issue with the integration of a third-party DLL into a custom data flow component.
The company sent me a C# project that generates a simple console application. The project includes a class that calls their DLL with DllImport. The console application runs fine.
I created a stand-alone class using the C# class they sent to expose the methods of their DLL. In my custom component, I'm referencing this class to pass data to and from their DLL.
The first method from that stand-alone class that my component encounters simply gets their installation path from the registry and does not use DllImport. That path retrieval works fine. The next method calls a function that is declared with DllImport. Each time the call fails with "System.DllNotFoundException = {"Unable to load DLL AMZip.dll': Exception from HRESULT: 0xE06D7363"}".
I've copied this DLL to countless locations (e.g., the PipelineComponents directory, the project/solution bin directory) and included these paths in all manner of path variables.
What am I missing here? Their DLL is not strong named (does this matter since I'm using DllImport?), my stand-alone class is, and of course, the custom component itself is. I appreciate the help.
I have the following stored proceduredrop procedure ce_selectCity;set ANSI_NULLS ONset QUOTED_IDENTIFIER ONGO-- =============================================-- Author: <Author,,Name>-- Create date: <Create Date,,>-- Description: <Description,,>-- =============================================create PROCEDURE ce_selectCity @recordCount int output -- Add the parameters for the stored procedure here --<@Param2, sysname, @p2> <Datatype_For_Param2, , int> = <Default_Value_For_Param2,, 0>AS declare @errNo int -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Insert statements for procedure here select ciId,name from ce_city order by name select @recordCount = @@ROWCOUNT select @errNo = @@ERROR if @errNo <> 0 GOTO HANDLE_ERROR return @errNoHANDLE_ERROR: Rollback transaction return @errNoGoand i was just testing it likeProtected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load db.connect() Dim reader As SqlDataReader Dim sqlCommand As New SqlCommand("ce_selectCity", db.getConnection) Dim recordCountParam As New SqlParameter("@recordCount", SqlDbType.Int) Dim errNoParam As New SqlParameter("@errNo", SqlDbType.Int) recordCountParam.Direction = ParameterDirection.Output errNoParam.Direction = ParameterDirection.ReturnValue sqlCommand.Parameters.Add(recordCountParam) sqlCommand.Parameters.Add(errNoParam) reader = db.runStoredProcedureGetReader(sqlCommand) If (db.isError = False And reader.HasRows) Then Response.Write("Total::" & Convert.ToInt32(recordCountParam.Value) & "<br />") While (reader.Read()) Response.Write(reader("ciId") & "::" & reader("name") & "<br />") End While End If db.close() End SubIt returns ALL ROWS (5 in the table right now). So, recordCount should be 5. (When i run it inside SQL Server (directly) it does return 5, so i know its working there).BUT, its returning 0.What am i doing wrong??EDIT:Oh, and this is the function i use to execute stored procedure and get the readerPublic Function runStoredProcedureGetReader(ByRef sqlCommand As SqlCommand) As SqlDataReader sqlCommand.CommandType = CommandType.StoredProcedure Return sqlCommand.ExecuteReader End Function
View 5 Replies View RelatedHi All,
I have created a stored procedure (in SQL Server 2005 - Developer) with input and output parameters. Please somebody let me know how I can call this store procedure from code behind using TableAdapter i.e. through XSD.
Thanks,
Long Live Microsoft ;)
I want to access a key from appSettings section of web.config.
I have the number of days allowed for a user to activate his/her account as a key in appSettings.
I have a maintenance procedure to delete all accounts that are not activated before that many days.
In this context, i have to access web.config from stored procedure. The procedure will be scheduled as a JOB in sql server.
Thanks.
Hiya folks,
I'n need to access a view from within a SProc, to see if the view returns a recordset and if it does assign one the of the fields that the view returns into a variable.
The syntax I'm using is as follows :
SELECT TOP 1 @MyJobN = IJobN FROM MyView
I keep getting an object unknown error (MyView). I've also tried calling it with the 'owner' tags.
SELECT TOP 1 @MyJobN = IJobN FROM LimsLive.dbo.MyView
But alas to no avail!
Any offers kind people??
i'm trying to insert into db sql 2000 through a stored procedure .. i got this error " Procedure or function newuser has too many arguments specified "
this is the procedure :
ALTER PROCEDURE newuser
(@username_1 [nvarchar](80),
@email_2 [nvarchar](50),
@password_3 [nvarchar](256),
@Country_ID_4 [int],
@city_id_5 [nvarchar](10),
@gender_6 [nvarchar](50),
@age_7 [int],
@fname_8 [nvarchar](50),
@lname_9 [nvarchar](50),
@birthdate_10 [datetime])
AS INSERT INTO [Brazers].[dbo].[users]
( [username],
[email],
[password],
[Country.ID],
[city.id],
[gender],
[age],
[fname],
[lname],
[birthdate])
VALUES
( @username_1,
@email_2,
@password_3,
@Country_ID_4,
@city_id_5,
@gender_6,
@age_7,
@fname_8,
@lname_9,
@birthdate_10)
& that 's the code in asp page :
Dim param As New SqlClient.SqlParameter
SqlConnection1.Open()
param.ParameterName = "@username_1"
param.Value = TextBox1.Text
param.Direction = ParameterDirection.Input
SqlCommand1.Parameters.Add(param)
SqlCommand1.ExecuteNonQuery()
plz .. waiting any solve for this problem immediately
hi
i have stored procedure and i need to access another database in my stored procedure
I'm going to query a table which is located in another database
as you know it is impossible to use the USE database keyword in stored procedures
so what should I do?
thanks.
Hi
I have a sql task in my control flow, which is like
Resultset = Single Row, SQL SourceType = Direct Input, SQL Stmt = EXEC StoreProcA ?
Result Name VariableName
StartDate UserStartDate
EndDate User:EndDate
Above SQL task is working fine... My question is I have an another SQL task immediately below that one.SQL Stmt is
SELECT CreditDebitDiff
FROM (SELECT C.BalanceNbr - D.BalanceNbr As CreditDebitDiff
FROM dbo.BalanceLog C, dbo.BalanceLog D
JOIN Work.CycleControl cc
ON cc.CycleControlId = D.CycleControlId
WHERE C.BalanceItemId = '81041'
AND D.BalanceItemId = '81031'
AND cc.CycleDate = ?) AS D
Parameter0 is mapped to User:EndDate and ResultName mapped to User:CreditDebitDiff (Datatype: Double)
SQL Task fails. I know I am making a mistake but dunno how to correct it. I can do it with a store proc but don't want to.
Any help would be greatly appreciated...
How do I search for and print all stored procedure names in a particular database? I can use the following query to search and print out all table names in a database. I just need to figure out how to modify the code below to search for stored procedure names. Can anyone help me out?
SELECT TABLE_SCHEMA + '.' + TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'
Hi,
Can anyone tell me how to access the results from a select statement within the stored procedure?
This is to implement auditting functionality, before updating a record i want select the original record and compare the contents of each field with the varibles that are passed in, if the fields contents has changed i want to write an audit entry.
So i'd like to store the results of the select statement in a variable and access it like a dataset. e.g
declare selectResult
set selectResult = Select field1,field2,field3 from table1
if selectResult.field1 <> @field1
begin
exec writeAudit @var1,@var2,var3
end
Many thanks.
I have a COM object that is written using Visual Basic 6. This is referenced in a .NET Stored Procedure. But when I execute the stored procedure I get an error:
Msg 6522, Level 16, State 1, Procedure prCalculator_ExecCalc, Line 0
A .NET Framework error occurred during execution of user defined routine or aggregate 'prCalculator_ExecCalc':
System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {844E8165-ABC1-432B-9490-51B1A6D91E71} failed due to the following error: 80040154.
System.Runtime.InteropServices.COMException:
Here is what I do:
1. Compile the VB DLL.
2. Convert into a .NET assembly by importing to a Visual Studio 2005 project. Sign the interop assembly.
3. Register it as an assembly in SQL 2005 server.
4. Create a .NET stored procedure and reference the above assembly. Compile this assembly again in SQL 2005 and create a stored procedure using the assembly. This assembly is also signed.
Please Note:
1. All the assemblies are registered with UNSAFE permissions.
2. They are compiled with COM Visible flag in Visual Studio 2005.
3. This works perfectly on my local SQL Express where I have Visual Basic/VisualStudio 2005 installed.
4. I get this error, when trying on Test Server. I tried to install the VB Runtime on this machine and still does not work.
So, what am I missing? Thanks for your help.
.
Hi,
I am new to Sql Server 2005 Reporitng Services. I created a report in BI and used stored procedure as a dataset. When I run the report in preview mode it works fine and when I run it in report server/report manager, I am getting the following error:
An error has occurred during report processing. (rsProcessingAborted)
Query execution failed for data set 'dsetBranch'. (rsErrorExecutingCommand)
Could not find stored procedure 'stpBranch'.
But I have this procedure in the db and it runs fine in the query analyzer and the query builder window in report project. When I refresh the page in Report manager, I am getting this error.
Input string was not in a correct format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.FormatException: Input string was not in a correct format.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[FormatException: Input string was not in a correct format.]
System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +2753715
System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +102
Microsoft.Reporting.WebForms.ReportAreaPageOperation.PerformOperation(NameValueCollection urlQuery, HttpResponse response) +149
Microsoft.Reporting.WebForms.HttpHandler.ProcessRequest(HttpContext context) +75
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +154
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64
I have changed the dataset from procedure to a sql string and the report is working fine everywhere. But I have a business requirement that I need to use a stored procedure.
I am not sure why I am getting this error and I greatly appreciate any help.
Thanks
Seems like I'm stealing all the threads here, : But I need to learn :) I have a StoredProcedure that needs to return values that other StoredProcedures return.Rather than have my DataAccess layer access the DB multiple times, I would like to call One stored Procedure, and have that stored procedure call the others to get the information I need. I think this way would be more efficient than accessing the DB multiple times. One of my SP is:SELECT I.ItemDetailID, I.ItemDetailStatusID, I.ItemDetailTypeID, I.Archived, I.Expired, I.ExpireDate, I.Deleted, S.Name AS 'StatusName', S.ItemDetailStatusID, S.InProgress as 'StatusInProgress', S.Color AS 'StatusColor',T.[Name] AS 'TypeName', T.Prefix, T.Name AS 'ItemDetailTypeName', T.ItemDetailTypeID FROM [Item].ItemDetails I INNER JOIN Item.ItemDetailStatus S ON I.ItemDetailStatusID = S.ItemDetailStatusID INNER JOIN [Item].ItemDetailTypes T ON I.ItemDetailTypeID = T.ItemDetailTypeID However, I already have StoredProcedures that return the exact same data from the ItemDetailStatus table and ItemDetailTypes table.Would it be better to do it above, and have more code to change when a new column/field is added, or more checks, or do something like:(This is not propper SQL) SELECT I.ItemDetailID, I.ItemDetailStatusID, I.ItemDetailTypeID, I.Archived, I.Expired, I.ExpireDate, I.Deleted, EXEC [Item].ItemDetailStatusInfo I.ItemDetailStatusID, EXEC [Item].ItemDetailTypeInfo I.ItemDetailTypeID FROM [Item].ItemDetails IOr something like that... Any thoughts?
View 3 Replies View RelatedGreetings:
I have MSSQL 2005. On earlier versions of MSSQL saving a stored procedure wasn't a confusing action. However, every time I try to save my completed stored procedure (parsed successfully ) I'm prompted to save it as a query on the hard drive.
How do I cause the 'Save' action to add the new stored procedure to my database's list of stored procedures?
Thanks!
Hello,
Kind of a .Net question, although specifically related to VSA.
We have a script task that references an external DLL. That DLL is a proxy for a web service and it takes its configuration info (e.g. location of the web service) from a configuration file.
We have created a quick-and dirty test harness exe to consume data using the proxy and it works fine. All you need to do is dump the proxy, the config file and the test harness exe into a folder.
This doesn't work so well when you substitute SSIS for the test harness. We are trying to use a script task which references the proxy DLL to get a response from the web service but when we execute we get:
"Cannot find default endpoint element that references contract 'blah blah blah' in the ServiceModel client configuration section. This might be because no configuration file was found for your application..."
[See a screenshot here: http://cid-550f681dad532637.skydrive.live.com/self.aspx/Public/Misc/ssis_script_task_config_error.JPG]
This makes sense of course, right? The DLL needs the config file. However, where do you put the config file so that the DLL (which, remember, is running inside SSIS) can find it? We've tried putting it in the same folder as the .dtsx file, in the same folder as dtexec.exe...nothing works.
To try and debug we put the following code into the script task:
Code Snippet
Dim rst_Path As String
rst_Path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName.CodeBase)
MsgBox(rst_Path)
and the resultant message box was contained "file:C:WINDOWSassemblyGAC_MSILMicrosoft_VsaVb8.0.0.0__<GUID>"
which makes complete sense of course.
So, my question is, how can we configure this whole kaboodle of "stuff" so that it works?
Thanks
Jamie
We recently upgraded to SQL Server 2005. We had several stored procedures in the master database and, rather than completely rewriting a lot of code, we just recreated these stored procedures in the new master database.
For some reason, some of these stored procedures are getting stored as "System Stored Procedures" rather than just as "Stored Procedures". Queries to sys.Objects and sys.Procedures shows that these procs are being saved with the is_ms_shipped field set to 1, even though they obviously were not shipped with the product.
I can't update the sys.Objects or sys.Procedures views in 2005.
What effect will this flag (is_ms_shipped = 1) have on my stored procedures?
Can I move these out of "System Stored Procedures" and into "Stored Procedures"?
Thanks!
Hello friends......How are you ? I want to ask you all that how can I do the following ?
I want to now that how many ways are there to do this ?
How can I call one or more stored procedures into perticular one Stored Proc ? in MS SQL Server 2000/05.
Hello
I'm start to work with SSIS.
We have a lot (many hundreds) of old (SQL Server2000) procedures on SQL 2005.
Most of the Stored Procedures ends with the following commands:
SET @SQLSTRING = 'SELECT * INTO ' + @OutputTableName + ' FROM #RESULTTABLE'
EXEC @RETVAL = sp_executeSQL @SQLSTRING
How can I use SSIS to move the complete #RESULTTABLE to Excel or to a Flat File? (e.g. as a *.csv -File)
I found a way but I think i'ts only a workaround:
1. Write the #Resulttable to DB (changed Prozedure)
2. create data flow task (ole DB Source - Data Conversion - Excel Destination)
Does anyone know a better way to transfer the #RESULTTABLE to Excel or Flat file?
Thanks for an early Answer
Chaepp
Hi
When images are uploaded and stored directly into a sql database as binary data (eg in the club starter kit) how can those images be accessed and displayed.
When I open the images table in VWD and select display data, the cells holding the image data hold a <binary data> tag. What I want to be able to do is get at that data, or actually get at the image so that it is displayed. My reason is this, at the moment the only way to access the images in the sql database after they have been uploaded is to log into the website and view them as an administrator of the site. It would be much simpler if I could access the database directly and view the contents of the images table.
Any ideas?
Thanks