Results 1 to 26 of 26

Thread: [RESOLVED] How can I backup an OPEN Server database?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2010
    Location
    Lake Gaston, NC
    Posts
    453

    Resolved [RESOLVED] How can I backup an OPEN Server database?

    I am using VB 2010 Professional and Server 2008.

    How can I backup an open Database? or is this even possible?

  2. #2
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: How can I backup an OPEN Server database?

    Check this post and the link within

    http://www.vbforums.com/showthread.p...=1#post2070901

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2010
    Location
    Lake Gaston, NC
    Posts
    453

    Re: How can I backup an OPEN Server database?

    My question really is about an OPEN DATABASE. Will "BackUp mydatabase to disk" work if the database is OPEN?

  4. #4
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: How can I backup an OPEN Server database?

    BACKUP is the only way to BACKUP a MS SQL database - and it's designed to work when the DB is open. That's the cool thing about MS SQL - it's perfect like that.

    If you don't do regular backup's your LOG file can grew like crazy. BACKUP is good.

    Do you understand how the LOG file works in MS SQL?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2010
    Location
    Lake Gaston, NC
    Posts
    453

    Re: How can I backup an OPEN Server database?

    Nope

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2010
    Location
    Lake Gaston, NC
    Posts
    453

    Re: How can I backup an OPEN Server database?

    THIS IS FROM A PREVIOUS POST WHICH I COULD NEVER RESOLVE.
    DO YOU HAVE ANY IDEA WHAT IS WRONG WITH THE CODE BELOW?


    Using VB 2010 Professional.

    I am trying to backup my Server 2008 Database for the first time using the code below.

    I am getting an error message" "Database AbcDatabase does not exist. Make sure the name is entered correctly." on the "SqlCmd.ExecuteNonQuery()" line.

    AbcDatabase is the correct name. What am I doing wrong?

    problem Code:
    1. Dim AbcServerDB As String = "C:\Program Files\Microsoft Sql Server\MSSQL10.SqlExpress\MSSQL\DATA\AbcDatabase.mdf"
    2.  
    3. If File.Exists(AbcServerDB) Then
    4.                Dim BackupCmptr As String = "AbcLaptop"
    5.                Dim DestinationFolderAndFile As String = "\\" & BackupCmptr & "\BackupAbcHal\AbcDatabase.bak"
    6.                Dim SqlConn As SqlConnection
    7.                Dim SqlCmd As SqlCommand
    8.                
    9. Dim sMyConnectionString As String = "Data Source=" & PrimaryServer _
    10.                       & "\SqlExpress; Database=C:\Program Files\Microsoft Sql   Server\MSSQL10.SqlExpress\MSSQL\DATA\AbcDatabase.mdf; " _
    11.                       & "User Id=abc99; Password=abc99password;"
    12.  
    13.                 SqlConn = New SqlConnection(sMyConnectionString)
    14.                 SqlConn.Open()
    15.                
    16. Dim ThisQuery As String = "backup database AbcDatabase to disk='\\NewAbcLaptop\BackupAbcHal\AbcDatabase.bak'"
    17.  
    18.                 SqlCmd = New SqlCommand(ThisQuery, SqlConn)
    19.                 SqlCmd.ExecuteNonQuery()
    20.  
    21.                 SqlConn.Close()

  7. #7
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: How can I backup an OPEN Server database?

    Connection strings do not take the "path" to a MDF - the INSTANCE of MS SQL that is running knows where the file is physically.

    Have you ever got a connection to this DB working - like elsewhere in your code?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2010
    Location
    Lake Gaston, NC
    Posts
    453

    Re: How can I backup an OPEN Server database?

    Many different programs over many months. What's wrong with the connection string? ie, how would you suggest that I change it? I'm still fairly new at .Net.

  9. #9
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: How can I backup an OPEN Server database?

    They look like this

    "Data Source=10.42.0.41\sqlexpress;Initial Catalog=TCS; User Id=abc; Password=xyz"

    SERVER name goes in DATA SOURCE and the DATABASE goes into INITIAL CATALOG.

    Unless you are trying to mount the DB on the initial open - that's kind of like how LOCALDB works (I believe - I don't use that MS SQL feature).

    Show a connection string from a program that is working.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2010
    Location
    Lake Gaston, NC
    Posts
    453

    Re: How can I backup an OPEN Server database?

    Well, aren't you the early bird. Thanks for your help and your helpful attitude!!

    I use this same connection string in all my programs that I have written so far and they all work just fine. I think I am connecting to the DB directly?.?

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2010
    Location
    Lake Gaston, NC
    Posts
    453

    Re: How can I backup an OPEN Server database?

    I got a log in failure on the string below in the TableAdapter.Fill statement. I do have have my connection string in my Load routine.

    Just tried this Code:
    1. Private Sub BackupPictures_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    2.         Try
    3.             Me.LocationTableTableAdapter.Fill(Me.AbcLocationDBDataSet.LocationTable)
    4.             PrimaryServer = txtLocPrimaryServer.Text
    5.  
    6.             'Dim sMyConnectionString As String = "Data Source=" & PrimaryServer _
    7.             '       & "\SqlExpress; Database=C:\Program Files\Microsoft Sql Server\MSSQL10.SqlExpress\MSSQL\DATA\AbcDatabase.mdf; " _
    8.             '       & "User Id=abc99; Password=abc99password;"
    9.  
    10.             Dim sMyConnectionString As String = "Data Source=" & PrimaryServer _
    11.                     & "\sqlexpress;Initial Catalog=AbcDatabase; User Id=abc99; Password=abc99password"
    12.  
    13.             Me.DealershipTableTableAdapter.Connection.ConnectionString = sMyConnectionString
    14.             Me.DealershipTableTableAdapter.Fill(Me.AbcDatabaseDataSet.DealershipTable)

  12. #12
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: How can I backup an OPEN Server database?

    Do you use SQL Server Management Studio to work with this SQL instance? Since SQL normally runs as a SERVICE on a SERVER or workstation it is usually talked to with SSMS.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2010
    Location
    Lake Gaston, NC
    Posts
    453

    Re: How can I backup an OPEN Server database?

    I have only been using SSMS to make changes to my database table. As you can probably tell, I am new at this and may be doing things incorrectly.

  14. #14
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: How can I backup an OPEN Server database?

    If you are using SSMS then you have an object explorer on the left you can open and see a branch for your DB. If that is the case then the DB is already mounted to the service running.

    Your connection string is not correct. Follow these three steps and make this same screen shot for me to see.
    Attached Images Attached Images  

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  15. #15

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2010
    Location
    Lake Gaston, NC
    Posts
    453

    Re: How can I backup an OPEN Server database?

    SZLAMANY, you are my hero.


    Lo and behold, when I looked at the screen shot of my SSMS, perched in the Database Name field was "Master" and not AbcDatabase.

    Backup Program works fine now with MASTER as the database name.

    Thanks again for all of your help!

  16. #16
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: [RESOLVED] How can I backup an OPEN Server database?

    GAAAAAH! MASTER? Noooooo! (slow motion leaping over chairs, reaching out)

    The master database is the main master database that SQL Server uses to maintain the list of databases and other internal states... good gawd man! Please tell me you didn't put your tables or do development in the master database!

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  17. #17
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: [RESOLVED] How can I backup an OPEN Server database?

    I'm afraid...

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  18. #18

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2010
    Location
    Lake Gaston, NC
    Posts
    453

    Re: [RESOLVED] How can I backup an OPEN Server database?

    Before we both panic, maybe I RCed the wrong line.

    If I expand Databases in SSMS there are 2 items "System Databases" and "a DB symbol with the full path to my DB"

    If I then RC the topmost line in the screen, that's where I see Master in the Database Name field.

    If, however, I RC "the Symbol with the full path to my DB", Click Properties, and then Click "View Connection Properties", I get the full path to my DB in the Database Name field.

    The Backup only works if I use Master as the Database.

  19. #19

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2010
    Location
    Lake Gaston, NC
    Posts
    453

    Re: [RESOLVED] How can I backup an OPEN Server database?

    I created my DB and Set up SSMS about a year and a half ago, when I first started learning .Net. I absolutely did not know what I was doing back then(self taught) and don't remember how I went about it.

    I get the correct DB, "AbcDatabase", in the backup folder when I run my backup.



    Dim ThisQuery As String = "backup database master to disk='\\" & BackupCmptr & "\BackupAbcHal\AbcDatabase.bak'"
    Last edited by DexterRose; Jun 25th, 2014 at 04:09 PM.

  20. #20
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: [RESOLVED] How can I backup an OPEN Server database?

    You are backing up a DATABASE called MASTER - so stop that immediately.

    You need to get your connection string working as I said in several posts.

    Until then you are simply masking problems.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  21. #21

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2010
    Location
    Lake Gaston, NC
    Posts
    453

    Re: [RESOLVED] How can I backup an OPEN Server database?

    I still don't know what Database Name I should use see attached ScreenShot


    Name:  SSMS.jpg
Views: 276
Size:  35.5 KB

  22. #22
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: [RESOLVED] How can I backup an OPEN Server database?

    I do not know how you got the DATABASE name to appear with a FOLDER in front of it.

    And that picture is simply not readable - the forum here has really messed that up on us.

    Argh!

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  23. #23

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2010
    Location
    Lake Gaston, NC
    Posts
    453

    Re: [RESOLVED] How can I backup an OPEN Server database?

    Try this picture.

    What Do you suggest that I do to change the database name at this point?


    Name:  SSMS pic2.jpg
Views: 313
Size:  27.0 KB

  24. #24

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2010
    Location
    Lake Gaston, NC
    Posts
    453

    Re: [RESOLVED] How can I backup an OPEN Server database?

    Should I just rename the Database here by right clicking the Database Name symbol shown under the "Server Databases" symbol, selecting Rename, and then changing the Database Name from "C:\Program Files............." to "AbcDatabase" ?

    Name:  SSMS pic3.jpg
Views: 242
Size:  13.4 KB

  25. #25
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: [RESOLVED] How can I backup an OPEN Server database?

    Yup.
    It probably got that way because of how you had the connection string in the first place and it got attached as a user instance or something. One way or another, it got created incorrectly.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  26. #26

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2010
    Location
    Lake Gaston, NC
    Posts
    453

    Re: [RESOLVED] How can I backup an OPEN Server database?

    Thanks to everyone for helping me solve this problem!!

Posting Permissions

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



Click Here to Expand Forum to Full Width