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_O BJECT_TYPE.SQLD MOObj_UserDefin edFunction,
SQLDMO.SQLDMO_O BJSORT_TYPE.SQL DMOObjSort_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_Link Clicked(object sender,
LinkLabelLinkCl ickedEventArgs e)
{
this.Cursor = Cursors.WaitCur sor;
SQLDMO.SQLServe r srv = new SQLDMO.SQLServe rClass();
srv.Connect(thi s.cboServers.Se lectedItem.ToSt ring(), this.txtUser.Te xt,
this.txtPasswor d.Text);
for (int i = 0; i < srv.Databases.C ount; i++)
{
if (srv.Databases. Item(i + 1, "dbo").Name ==
this.cboDatabas e.SelectedItem. ToString())
{
SQLDMO._Databas e db = srv.Databases.I tem(i + 1, "dbo");
this.lstObjects .Items.Clear();
SQLDMO.SQLObjec tList sqludf;
sqludf =
db.ListObjects( SQLDMO.SQLDMO_O BJECT_TYPE.SQLD MOObj_UserDefin edFunction,
SQLDMO.SQLDMO_O BJSORT_TYPE.SQL DMOObjSort_Name );
for (int j = 0; j < sqludf.Count; j++)
{
//this.lstObjects .Items.Add(db.L istObjects(SQLD MO.SQLDMO_OBJEC T_TYPE.SQLDMOOb j_UserDefinedFu nction,
SQLDMO.SQLDMO_O BJSORT_TYPE.SQL DMOObjSort_Name ).Item(j + 1, "dbo").Name );
}
this.Cursor = Cursors.Default ;
return;
}
}
this.Cursor = Cursors.Default ;
}
Comment