ambiguous reference to Table

Last post 11-22-2009 5:10 PM by PeteNet. 2 replies.

Sort Posts:

  • ambiguous reference to Table

    11-22-2009, 2:45 PM
    • Member
      12 point Member
    • diana_011
    • Member since 11-22-2009, 7:37 PM
    • Posts 15

    hi,

    i'm using SMO instance objects to create a table, but i got the error:

    Error 1 'Table' is an ambiguous reference between 'System.Web.UI.WebControls.Table' and 'Microsoft.SqlServer.Management.Smo.Table' C:\smo\Default2.aspx.cs 24 9 C:\smo\

    how can i resolve this ambiguity

     

    thanks.

  • Re: ambiguous reference to Table

    11-22-2009, 5:06 PM
    • Contributor
      3,384 point Contributor
    • Danish Ali
    • Member since 08-08-2008, 11:22 PM
    • Fort Lauderdale, US
    • Posts 468

    Use complete Namespace with the declaration of your table object.

    for example;

    //vb code

    dim mytable as new Microsoft.SqlServer.Management.Smo.Table()

    // c# code

    Microsoft.SqlServer.Management.Smo.Table mytable=new Microsoft.SqlServer.Management.Smo.Table();


    In case it don't help then please post your code.



    If my post solves your problem, please mark it as an answer.
  • Re: ambiguous reference to Table

    11-22-2009, 5:10 PM
    Answer
    • All-Star
      32,712 point All-Star
    • PeteNet
    • Member since 01-21-2009, 1:15 PM
    • Posts 4,621

    you probably have code that starts like this:

    Table table = new Table(); //..........etc

    a simple way to help the compiler know which table you're actually working with (between the two) would be to fully qualify it:

    Microsoft.SqlServer.Management.Smo.Table table = new Microsoft.SqlServer.Management.Smo.Table();

    you can also form your own alias for the namespace, something like:

    using MySMO = Microsoft.SqlServer.Management.Smo;

    and then in code:

    MySMO.Table table = new MySMO.Table();


    some references: http://en.csharp-online.net/CSharp_FAQ:_How_use_an_alias_for_a_class_or_namespace

    http://www.devx.com/tips/Tip/34419


    * for VB.NET convert here: http://www.developerfusion.com/tools/convert/csharp-to-vb/

    Regards,
    Peter
Page 1 of 1 (3 items)