Results 1 to 14 of 14
  1. #1
    Join Date
    Jan 2004
    Posts
    5

    Unanswered: The SQL Namespace has already been initialized.

    I am trying to build a SQL Server 2000 (sp3) admin app in VB.NET that gives the users targeted access to EM functions without having to search through EM. At any rate, I cannot seem to re-initialize the SQL namespace, even after setting it to nothing (I want to enable a user to do work with one server, pop into another, etc). Here is a sample of what I am doing, stripped to its essentials. This code fails with the error in the subject line. Thanks in advance.

    Dim NS As New SQLNS.SQLNamespace, Str as String

    Str = "Server=SQLTEST;Trusted_Connection=Yes;"
    NS.Initialize("Application; ", SQLNS.SQLNSRootType.SQLNSRootType_Server, _
    Str, Handle.ToInt32)
    NS = Nothing
    NS = New SQLNS.SQLNamespace
    Str = "Server=SQLPROXY;Trusted_Connection=Yes;"
    NS.Initialize("Application; ", SQLNS.SQLNSRootType.SQLNSRootType_Server, _
    Str, Handle.ToInt32)
    NS = Nothing
    Last edited by ralphmast; 01-12-04 at 16:41.

  2. #2
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    First of all, you're using early binding. Second of all, you're DIMming the variable as New. Try to either use late binding, or Dim As SQLNS.SQLNamespace...and then instantiate. Doing so will allow you to successfully set it to nothing and then re-instantiate.

  3. #3
    Join Date
    Jan 2004
    Posts
    5
    Thanks for your reply. Here is my re-write. I am still getting the same error.

    Dim NS As Object

    NS = CreateObject("SQLNS.SQLNamespace")
    NS.Initialize("Application; ", SQLNS.SQLNSRootType.SQLNSRootType_Server, _
    "Server=SQLTEST;Trusted_Connection=Yes;", Handle.ToInt32)
    NS = Nothing

    NS = CreateObject("SQLNS.SQLNamespace")
    NS.Initialize("Application; ", SQLNS.SQLNSRootType.SQLNSRootType_Server, _
    "Server=SQLPROXY;Trusted_Connection=Yes;", Handle.ToInt32)
    NS = Nothing




    Originally posted by rdjabarov
    First of all, you're using early binding. Second of all, you're DIMming the variable as New. Try to either use late binding, or Dim As SQLNS.SQLNamespace...and then instantiate. Doing so will allow you to successfully set it to nothing and then re-instantiate.

  4. #4
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    I'm sorry I can't help...but what are you trying to accomplish...

    Just curious...
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  5. #5
    Join Date
    Jan 2004
    Posts
    5
    The DBA's in our shop have to support Allbase, Oracle, Sybase, Informix, and SQL Server. Therefore, automation is crucial. I am trying to build an application that pulls all the tools a SQL Server DBA might need to maintain multiple remote installs into one place. Enterprise Manager is a good tool, but a bit cumbersome for a DBA used to UNIX command line interfaces. It also does not give much access to Windows OS functions.

  6. #6
    Join Date
    Feb 2004
    Posts
    5
    I am having the same problem, can you let me know if you or anybody have solved this problem and how have you resolved it?

    this is the background of my problem. I am writing an application where the users can run the dts packages from different server databases. When i install the application, is sql server needed to be installed at the user's machine? I am using SQL Namespaces to invoke the Enterprice Manager UI so that the user would see the steps when the dts package runs.

    Thanks in advance!

  7. #7
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    Isn't there a way to reuse the same namespace object without having to destroy/recreate it for each server you're trying to connect to? Isn't there something like .Close/.Connect methods?

  8. #8
    Join Date
    Feb 2004
    Posts
    5
    Well, there is no .close or .connection method to use. The first time the function get executed, it works fine, at the end of the function, i even set the objec to null ( i am using c#). However, the second timethe function get called, the connection to the enterprice manager still exists. I need to kill the connection ( the object), but setting to null does not work. I am using SQLNamespace object.

    Thanks.

  9. #9
    Join Date
    Feb 2004
    Posts
    5
    I finally solved the problem by using this:

    GC.Collect() to force collection of existing COM Objects waiting to be released.


    Thanks for helping.

  10. #10
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    What's GC? Same as NS?

  11. #11
    Join Date
    Feb 2004
    Posts
    5
    GC stands for garbage collection. it forces the garbage collector to clean up resources.

  12. #12
    Join Date
    Jan 2004
    Posts
    5
    Thanks for the tip on the GC. Works like a charm!

  13. #13
    Join Date
    Feb 2004
    Posts
    5
    I am having problem with installing the application that uses the SQL Namespaces.

    I am trying to install the application on user's computer without having to install the sql server. I used .net set up and delopyment project to create a bundle to include all my files for the appliation. When i installed it in the user's computer without the sql server, i have an error:

    See the end of this message for details on invoking
    just-in-time (JIT) debugging instead of this dialog box.

    ************** Exception Text **************
    System.IO.FileNotFoundException: File or assembly name Interop.SQLNS, or one of its dependencies, was not found.
    File name: "Interop.SQLNS"
    at Recon_Runner.frmMain2.DTSExecuteSQLNamespace(Strin g sPackageName, String sServer, String sUID, String sPwd)
    at Recon_Runner.frmMain2.SetToRunRecon(String sDTSName, String sCategory, Label lblLabel)
    at Recon_Runner.frmMain2.btnAutoRun_Click(Object sender, EventArgs e)
    at System.Windows.Forms.Control.OnClick(EventArgs e)
    at System.Windows.Forms.Button.OnClick(EventArgs e)
    at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
    at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.ButtonBase.WndProc(Message& m)
    at System.Windows.Forms.Button.WndProc(Message& m)
    at System.Windows.Forms.ControlNativeWindow.OnMessage (Message& m)
    at System.Windows.Forms.ControlNativeWindow.WndProc(M essage& m)
    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

    === Pre-bind state information ===
    LOG: DisplayName = Interop.SQLNS, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null
    (Fully-specified)
    LOG: Appbase = C:\Documents and Settings\user\Desktop\New Folder\
    LOG: Initial PrivatePath = NULL
    Calling assembly : Recon_Runner, Version=1.0.1495.27523, Culture=neutral, PublicKeyToken=null.
    ===

    Please help on how to go about installing this application without having sql server installed.

    Thanks very much.

  14. #14
    Join Date
    Jan 2004
    Posts
    5
    Your best bet is to install the SQL Server client tools. Short of that, you would need to install a rather large number of dll's on your client machine.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •