473,480 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

SQL-DMO and C#: retrieve the list of User-Defined Functions

http://www.csharphelp.com/archives2/archive342.html

I am using the sample code from this link but I am
unable to figure out how to retrieve the list of
the User-Defined Functions. I am able to get the
count of the user defined functions correctly using:

db.ListObjects(SQLDMO.SQLDMO_OBJECT_TYPE.SQLDMOObj _UserDefinedFunction,
SQLDMO.SQLDMO_OBJSORT_TYPE.SQLDMOObjSort_Name).Cou nt

but I am unable to get to enumerate the function names.

Then I tried to see if I can achieve what I want using
SQLObjectList but I was unsuccessful.

Does someone know how I can do this using C#?

Thank you

This is the full code I have:

private void linkLabel5_LinkClicked(object sender,
LinkLabelLinkClickedEventArgs e)
{
this.Cursor = Cursors.WaitCursor;
SQLDMO.SQLServer srv = new SQLDMO.SQLServerClass();
srv.Connect(this.cboServers.SelectedItem.ToString( ), this.txtUser.Text,
this.txtPassword.Text);
for (int i = 0; i < srv.Databases.Count; i++)
{
if (srv.Databases.Item(i + 1, "dbo").Name ==
this.cboDatabase.SelectedItem.ToString())
{
SQLDMO._Database db = srv.Databases.Item(i + 1, "dbo");
this.lstObjects.Items.Clear();
SQLDMO.SQLObjectList sqludf;
sqludf =
db.ListObjects(SQLDMO.SQLDMO_OBJECT_TYPE.SQLDMOObj _UserDefinedFunction,
SQLDMO.SQLDMO_OBJSORT_TYPE.SQLDMOObjSort_Name);
for (int j = 0; j < sqludf.Count; j++)
{
//this.lstObjects.Items.Add(db.ListObjects(SQLDMO.SQ LDMO_OBJECT_TYPE.SQLDMOObj_UserDefinedFunction,
SQLDMO.SQLDMO_OBJSORT_TYPE.SQLDMOObjSort_Name).Ite m(j + 1, "dbo").Name);
}
this.Cursor = Cursors.Default;
return;
}
}
this.Cursor = Cursors.Default;
}
Apr 8 '06 #1
4 5814
hi,
serge wrote:
http://www.csharphelp.com/archives2/archive342.html

I am using the sample code from this link but I am
unable to figure out how to retrieve the list of
the User-Defined Functions. I am able to get the
count of the user defined functions correctly using:

db.ListObjects(SQLDMO.SQLDMO_OBJECT_TYPE.SQLDMOObj _UserDefinedFunction,
SQLDMO.SQLDMO_OBJSORT_TYPE.SQLDMOObjSort_Name).Cou nt

but I am unable to get to enumerate the function names.

Then I tried to see if I can achieve what I want using
SQLObjectList but I was unsuccessful.

Does someone know how I can do this using C#?

Thank you

This is the full code I have:

private void linkLabel5_LinkClicked(object sender,
LinkLabelLinkClickedEventArgs e)
{
this.Cursor = Cursors.WaitCursor;
SQLDMO.SQLServer srv = new SQLDMO.SQLServerClass();
srv.Connect(this.cboServers.SelectedItem.ToString( ),
this.txtUser.Text, this.txtPassword.Text);
for (int i = 0; i < srv.Databases.Count; i++)
{
if (srv.Databases.Item(i + 1, "dbo").Name ==
this.cboDatabase.SelectedItem.ToString())
{
SQLDMO._Database db = srv.Databases.Item(i + 1, "dbo");
this.lstObjects.Items.Clear();
SQLDMO.SQLObjectList sqludf;
sqludf =
db.ListObjects(SQLDMO.SQLDMO_OBJECT_TYPE.SQLDMOObj _UserDefinedFunction,
SQLDMO.SQLDMO_OBJSORT_TYPE.SQLDMOObjSort_Name);
for (int j = 0; j < sqludf.Count; j++)
{

//this.lstObjects.Items.Add(db.ListObjects(SQLDMO.SQ LDMO_OBJECT_TYPE.SQLDMOObj_UserDefinedFunction,
SQLDMO.SQLDMO_OBJSORT_TYPE.SQLDMOObjSort_Name).Ite m(j
+ 1, "dbo").Name); } this.Cursor = Cursors.Default;
return;
}
}
this.Cursor = Cursors.Default;
}


try using the SQLDMO.Database2 interface, as the original one does not
provide functionnalities to access SQL Server 2000 new features..
--
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz/DbaMgr.shtm http://italy.mvps.org
DbaMgr2k ver 0.18.0 - DbaMgr ver 0.62.0
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
--------- remove DMO to reply
Apr 9 '06 #2
Hi Serge,

As well as using SQLDMO, you could also query the built-in sysobjects
table to get the names of your UDFs, e.g.

SELECT [name] AS [UDF Name]
FROM sysobjects
WHERE xtype = 'FN' or xtype = 'IF'
ORDER BY [name]

FN = Scalar function
IF = In-lined table-function

HTH,

Chris

Apr 9 '06 #3
Thank you Chris.

I would still hope someone knows how to achieve this using SQL-DMO.
Obviously using SQL-DMO I am able to get the count of the user-defined
functions so I am hoping someone who knows C# and/or SQL-DMO would
be able to tell me what I need to write to make this code show me the
function name or the SQL object name using SQLObjects..

Apr 10 '06 #4
Thank you Andrea, I will look at the SQLDMO.Database2 interface.

P.S.
I am not sure why my I didn't get your post downloaded to my news
reader. I read your email through Google.

Apr 12 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
12638
by: Peter | last post by:
I run most of my SQL scripts via kornshell on AIX. I use the "here-document" to run some of the smaller ones. Example: #!/bin/ksh # Analyze the table. sqlplus...
6
6747
by: Andreas Lauffer | last post by:
I changed from Access97 to AccessXP and I have immense performance problems. Details: - Access XP MDB with Jet 4.0 ( no ADP-Project ) - Linked Tables to SQL-Server 2000 over ODBC I used...
4
8051
by: MD | last post by:
I am trying to create a dynamic SQL statement to create a view. I have a stored procedure, which based on the parameters passed calls different stored procedures. Each of this sub stored procedure...
14
2925
by: diskoduro | last post by:
Hi!! Years ago I built a database to control the production of a little factory. The users wanted to work in a Windows Net workgroup so I created an mdb with all the tables and data an after...
7
3189
by: JIM.H. | last post by:
Hello, Is there any difference to between SLQ string in the code and call execute query and call a stored procedure and execute the query that way concerning speed, effectiveness, reliability,...
1
7125
by: QLD_AU | last post by:
Has anyone see the following error ? VS 2005 Installs ok, however the SQL Mobile Edition (part of a full install) fails with the following error ? With Thanks Jason
1
6589
by: Peter | last post by:
I've purchased VS.NET 2005 Standard and have tried to install SQL Server 2005 Express, but get the following error in the error log. Please could someone help me.... Microsoft SQL Server 2005...
1
1882
by: Ted | last post by:
I managed to get it installed OK, along side MS Visual Studio 2005 (with which I received it). During the install, I made sure I installed everything. I have developed a number of applications...
14
2997
by: Developer | last post by:
Hello All, i have recently installed VS2005 and was trying to install SQL sever 2000. I have Win XP' SP2. But when I tried installing, it only installed client tools and not the database. Can...
7
4030
by: Mike1961 | last post by:
Hi there. Well the situation is this, I have two tables: 1) tbl_registry where rows with code = 123 are 35 ; 1) tbl_Registered where rows with code = 123 are 43 In tbl_Registered I have...
0
7041
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
6739
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6929
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5337
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4779
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4481
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
563
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
181
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.