LinqToSql + Sql Server Express Backup/Restore + SMO
-
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