Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. LINQ
  4. LinqToSql + Sql Server Express Backup/Restore + SMO

LinqToSql + Sql Server Express Backup/Restore + SMO

Scheduled Pinned Locked Moved LINQ
databasehelpsql-serverquestioncsharp
1 Posts 1 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    Yasser Daheek
    wrote on last edited by
    #1

    hi guys lately I've been experiencing LinqToSql + Sql Server Express 2005, and it was a great journey (muddy) anyway .... I'm at the point that I want to make a Backup/Restore for the database the Backup went normal by executing the TSQL on the DataContext, but the Restore: I tried many ways, but failed...... we can't execute Restore on the same database we need to use the Master or other database which I failed accomplishing by executing "User Master" on the DataContext, ........ and I don't want to use the SqlBulkCopy so I went to SMO I tried the next code (code in my project doesn't look like this,.... I was just testing some thigs, to get an idea, cuz it really needs to get optimized)

        Dim db As PhoneBookDC = PhoneBookDC.GetDC
        Dim conbldr As New SqlConnectionStringBuilder(db.Connection.ConnectionString)
        Dim user = db.ExecuteQuery(Of String)("select current\_User").FirstOrDefault
        Dim DBName = db.ExecuteQuery(Of String)("select Db\_Name()").FirstOrDefault
        Dim SrvrName = db.ExecuteQuery(Of String)("select @@ServerName").FirstOrDefault
        MsgBox(SrvrName & vbCrLf & conbldr.DataSource) 'these differ in my project, is it common ?
        '----try 2 connect 2 Server 2 do Backup/Restore ------
        Dim srv1 As New Server(conbldr.DataSource)
        MsgBox(srv1.Databases.Contains(DBName)) 'my db is not in here
        Dim srv2 As New Server(SrvrName) 'this doesn't even connect
        MsgBox(srv2.Databases.Contains(DBName)) 'Error : "Failed to connect to server \[SrvrName\]"
    

    and I tried to connect to the database "Master" to do the work and worked .... but the problem that evey time I do I log in as "guest" which doesn't allow me doing the Backup/Restore ..... even when I put the user name "dbo" in the ConnectionString it still connect as "guest" actully I'm not sure about the right forum to post in... is it .NetFramework, VB.Net ....LinqToSql .... so I'm sorry if I missed it :-O (anyway ...... I've posted the same question in another forum, I'm saying this to not get any one saying things that I didn't tell ...) can any one help me out .......... a link , a book , an article , an advice .... thanks in advance

    Name: Yasser Daheek AKA vbnetskywalker B Date: 1/April/1987 Home: Syria - Hama Phone: 963967398199 Job: Hope to be a programmer , but to people ... seems like it's not a job

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups