Results 1 to 8 of 8
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    register db sql on sql server (6.0)

    Exisitis a script or code via VB classic to register a sql db directly in server sql istance?
    ... in effect have a sql db into a dir c:scriptmydbmydbsql
    and i want to register mydbsql in my server.
    or... in other words: i have dowloded a script in vb from a site, and this script use a sql db.
    I ma a newbie with sql server (my knoledgnmet is 40% about this type of server )
    To test this script i have instlled a sql express free (msde)
    Now, inested to use the graphical tool to conect this db in my actully server, i want to attache in this database , from the dir of script, via visual basic...

  2. Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: register db sql on sql server (6.0)

    Not a tool I use as I use the full blown product but there is a walk through on the Microsoft sitehere
    Jerry

  4. #3
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: register db sql on sql server (6.0)

    This is the link to attach the database from the command line

    http://msdn2.microsoft.com/en-us/library/ms165673.aspx
    Jerry

  5. #4
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: register db sql on sql server (6.0)

    (Edited by HansV to make URL clickable - you only have to put <!t><!/t> before and <!t><!/t> after the web address.

    Sal, you have been asked this before. Posting a clickable link instead of just a URL is very little work, and it is much more friendly towards Loungers reading your post.)


    Hi Jerry...

    In other case i have see this but... found this script from MS but have variuos error of syntiax:
    (http://msdn2.microsoft.com/it-it/library/s...ame(VS.80).aspx)

    Sub Main()
    Try
    Dim connectString As String = _
    "Server=(local);" & _
    "Integrated Security=True"
    Dim builder As New SqlConnectionStringBuilder(connectString)
    Console.WriteLine("Original: " & builder.ConnectionString)
    Console.WriteLine("AttachDBFileName={0}", _
    builder.AttachDBFilename)
    builder.AttachDBFilename = "C:MyDatabase.mdf"
    Console.WriteLine("Modified: " & builder.ConnectionString)

    Using connection As New SqlConnection(builder.ConnectionString)
    connection.Open()
    ' Now use the open connection.
    Console.WriteLine("Database = " & connection.Database)
    End Using

    Console.WriteLine("Press any key to finish.")
    Console.ReadLine()

    Catch ex As Exception
    Console.WriteLine(ex.Message)
    End Try
    End Sub

  6. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: register db sql on sql server (6.0)

    Sal, that code is for VB.Net, not for VB6. If you want code for "classic VB", you'll have to search for solutions using VB6.

  7. #6
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: register db sql on sql server (6.0)

    :-(...vb.net.........

    Idea for vb classic?

  8. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: register db sql on sql server (6.0)

    No, I have no experience with this subject.

  9. #8
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    5,896
    Thanks
    0
    Thanked 86 Times in 82 Posts

    Re: register db sql on sql server (6.0)

    Sal,
    Can you clarify what exactly you are trying to do? Your first post mentioned registering a database on a SQL Server but that script you posted appears to be for creating a connection to a database using ADO.Net. Which are you trying to do? If it's the former, then I think you need to create a connection to the database in ADO (I know you know how to do that by now), and then execute the sp_attach_db stored procedure - so something like:
    <code>cnn.execute "exec sp_attach_db @dbname='NameHere', @filename1='C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLDataDatabase.mdf', @filename2='C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLDataDatabaselog.ldf'"</code>
    should probably do it - I'm afraid I can't test that at work and have never had to do it in code before, but that's effectively the code equivalent of how you would do it manually.
    HTH
    Regards,
    Rory
    Microsoft MVP - Excel.

Posting Permissions

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