You are here: SQL-DMO and C#: retrieve the list of User-Defined Functions « MsSQL Server « IT news, forums, messages
SQL-DMO and C#: retrieve the list of User-Defined Functions

Posted by serge on 10/02/88 11:44

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).Count

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.SQLDMO_OBJECT_TYPE.SQLDMOObj_UserDefinedFunction,
SQLDMO.SQLDMO_OBJSORT_TYPE.SQLDMOObjSort_Name).Item(j + 1, "dbo").Name);
}
this.Cursor = Cursors.Default;
return;
}
}
this.Cursor = Cursors.Default;
}

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация