|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Get collation listTried this: [C# code] using Microsoft.SqlServer.Management.Smo; Server srv = ...; DataTable collations = srv.EnumCollations(); but it returns an empty DataTable, i wish to fetch it somehow. SELECT * FROM ::fn_helpcollations() it works fine from sqlcmd shell, how to do it in C#? I know in DMO there was a method ListCollations(), but I wish to use either Smo or sql commands, thanks Hi Christof,
It looks like a bug in our code, this function is supposed to do what you need. Can you give us more details about your code? What else are you doing before trying to enumerate the collations? -- Show quoteCiprian Gerea SDE, SqlServer This posting is provided "AS IS" with no warranties, and confers no rights. "christof" <nom***@nomail.de> wrote in message news:O4OXwp1TGHA.4976@TK2MSFTNGP11.phx.gbl... > Is there a way do programmable get a Collation list from server? > Tried this: > > [C# code] > using Microsoft.SqlServer.Management.Smo; > > Server srv = ...; > DataTable collations = srv.EnumCollations(); > > but it returns an empty DataTable, i wish to fetch it somehow. > > SELECT * > FROM ::fn_helpcollations() > > it works fine from sqlcmd shell, how to do it in C#? > I know in DMO there was a method ListCollations(), but I wish to use > either Smo or sql commands, > > thanks bug? I just tried it and it returned the list just fine.
Server srv = new Server(); foreach (DataRow r in srv.EnumCollations().Rows) { System.Diagnostics.Debug.WriteLine(r["Name"]); } 'ConsoleApplicationSMODemo.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\System.Transactions\2.0.0.0__b77a5c561934e089\System.Transactions.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'ConsoleApplicationSMODemo.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. Albanian_BIN Albanian_BIN2 Albanian_CI_AI Albanian_CI_AI_KS .... -- Show quote-oj "Ciprian Gerea [MSFT]" <Ciprian.Ge***@online.microsoft.com> wrote in message news:eBP0%23j8TGHA.4900@TK2MSFTNGP12.phx.gbl... > Hi Christof, > > It looks like a bug in our code, this function is supposed to do what you > need. Can you give us more details about your code? What else are you > doing before trying to enumerate the collations? > > -- > Ciprian Gerea > SDE, SqlServer > > This posting is provided "AS IS" with no warranties, and confers no > rights. > > > "christof" <nom***@nomail.de> wrote in message > news:O4OXwp1TGHA.4976@TK2MSFTNGP11.phx.gbl... >> Is there a way do programmable get a Collation list from server? >> Tried this: >> >> [C# code] >> using Microsoft.SqlServer.Management.Smo; >> >> Server srv = ...; >> DataTable collations = srv.EnumCollations(); >> >> but it returns an empty DataTable, i wish to fetch it somehow. >> >> SELECT * >> FROM ::fn_helpcollations() >> >> it works fine from sqlcmd shell, how to do it in C#? >> I know in DMO there was a method ListCollations(), but I wish to use >> either Smo or sql commands, >> >> thanks > > EnumCollations works just fine.
Server srv = new Server(); foreach (DataRow r in srv.EnumCollations().Rows) { Console.WriteLine(r["Name"]); } -- Show quote-oj "christof" <nom***@nomail.de> wrote in message news:O4OXwp1TGHA.4976@TK2MSFTNGP11.phx.gbl... > Is there a way do programmable get a Collation list from server? > Tried this: > > [C# code] > using Microsoft.SqlServer.Management.Smo; > > Server srv = ...; > DataTable collations = srv.EnumCollations(); > > but it returns an empty DataTable, i wish to fetch it somehow. > > SELECT * > FROM ::fn_helpcollations() > > it works fine from sqlcmd shell, how to do it in C#? > I know in DMO there was a method ListCollations(), but I wish to use > either Smo or sql commands, > > thanks oj wrote:
> EnumCollations works just fine. Thank you very much, works fine now for me too!> > Server srv = new Server(); > > foreach (DataRow r in srv.EnumCollations().Rows) > > { > > Console.WriteLine(r["Name"]); > > > > } Mistake I've made was here: DataTable collations = srv.EnumCollations(); I thought it would fetch my DataTable, I didn't do enumeration. foreach(.... ) |
|||||||||||||||||||||||