Showing error while back up the database in sql server - c#

I am facing some error while i am trying to back up my database in sql server R2.
it is showing the following error:
TITLE: Microsoft SQL Server Management Studio
Restore failed for Server 'Ironhide\SQLEXPRESS'. (Microsoft.SqlServer.SmoExtended)
ADDITIONAL INFORMATION:
System.Data.SqlClient.SqlError: The media set has 2 media families but only 1 are provided. All members must be provided. (Microsoft.SqlServer.Smo)

This i commonly a problem with how the database backup was taken, it looks like when the backup was created it was split into two files, you wont be able to restore it unless you have both those files. Try creating the backup again but when you do the backup insure that you only have one file in the destination section.

This question has been already asked in SO: Any other solutions for SQL's “The media set has 2 media families but only 1 are provided. All members must be provided.” error?
Anyway, your backup set was splitted in two files, but you're trying to restore the data from just only one backup file.
One solution is to backup your data in just one file and repeat the restore process. The other one is to provide both backup files and try to restore again the data. In this way, SQL Server won't warn you again with that error.
The Microsoft Project Manager for SQL Backup explains here the error.

Related

Cannot open database "ASPState" requested by the login. The login failed. Login failed for user 'xxxx'

I am working on one project which is in Asp.Net web form and Sql server. When I run application I get the error Unable to connect Sql Server Session Database and inner exception is Cannot open database ASPState requested by the login.
I did some google search to fix this issue. I don't have sa password so i cannot logged in as sa to assign privileges to ASPState database for the newly created User.
I don't see any ASPState database on Sql Server when i logged in. So i thought I might need to run aspnet reg exe on my machine. So i tried to run aspnetreg_regsql.exe but i got the following error.
An error occurred during the execution of the SQL file
'InstallCommon.sql'. The SQL error number is 5170 and the SqlException
message is: Cannot create file 'C:\Program Files\Microsoft SQL
Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\aspnetdb.mdf' because it
already exists. Change the file path or the file name, and retry the
operation.
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
Creating the aspnetdb database...
I am totally blank now to solve this issue, I will really appreciate your suggestion for this. This issue hold to publish on production.
Dont think that there is a simple answer to this with the permissions that you have, I think that what has happened is that the database HAS been created, but the user you are using does not have any access to it at all.
Without having an administrators credentials I dont think that you will be able to resolve the problem.
You can however work around it by re-creating the database with a different name:
aspnet_regsql -d[YourNewDBName] -RestOfYourParamaters
That should allow you to re-run the creation script, however there is no guarantee that you wont end up with the same issue on the newly created database.
You should issue the command DROP DATABASE aspnetdb and then re-run your script.
'InstallCommon.sql' surely ain't any database. It must be a script that installs a new Database, as the name suggests. Run the script, and then link the generated database

c# window application system.data.oledb.oledbexception operation must use an updateable query

I have made a window application that works very well when i ran through but after creating its setup it is throwing below mentioned exception. I have try to give full access to the database file but still it is not working.
system.data.oledb.oledbexception operation must use an updateable.
query
i am using window 7 and installation folder is c:\program files\abc\ and access db is in same folder. Is this any issue of permissions? Please assist me to remove this exception.
There can be some permission issue just refer this Link
http://www.mikesdotnetting.com/Article/74/Solving-the-Operation-Must-Use-An-Updateable-Query-error
Make sure the ASPNET account (or whatever account is in use at the time) has
Change permissions to the directory where the .mdb file is located. Access
needs to write some temp and locking files during the operation.

Restoring database to a new server with a new name

I am trying to create backup and restore of a database to new server with new name using C# and SQL server database. I can create a backup of the database but I am not able to restore it to the new server using the new name.
My query looks something like this: it doesn't work and errors out:
RESTORE DATABASE test1 FROM DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\setupdb\BackupForsetupdb.bak'
WITH MOVE 'setupdb_Data' TO '\\newserver\e$\MSSQL\DATA\test1_Data.MDF',
MOVE 'setupdb_log' TO '\\newserver\e$\MSSQL\DATA\test1_Log.LDF';
I am trying to achieve this through C# code.It looks like the database cannot be restored to the remote servers. Please throw some light on this.
Thanks!
You can't have SQL Server databases on network shares normally: local/SAN type drives only
The backup file can be on a share but the MDF and LDFs must be local
There is an MS KB article on it: it can be done but at your own risk
Your paths for the move command have to be relative to the server.
e:\MSSQL\Data\test1_data.mdf
And your restore from path has to be relative to the server as well. If the c:\ is from your local machine, you either need to point it to a UNC path (\\yourpc\c$\...) or move it to the server. But be aware that if using the UNC path option, the user the server process is running as has to have permissions to access the share as well. So you're probably better off copying to a drive on the remote computer.

connect to .mdf file in vs2010 , wpf application

I am using VS2010 , and I built a .mdf file using SQL server 2008
I want to use this database file in my wpf application so that I can add rows to it and delete rows from it
the problem is , I can't access this file , and all the insertion and deleting is actually hapening to the datacontexct i created .
I used myDataContexct.Submitchanges() but it didn't work either
I tried to add a connection string when I define the datacontexct that holds the url of my .mdf file and this it gave me a runtime error when trying to access this file and the error messege says :
An attempt to attach an auto-named database for file Trial.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
please help me because I searched alot but I couldn't find any help
If the application is not going to be installed in a manner that many clients are accessing the same server, you would want to consider using SQL Server Compact Edition.
Are you sure the connection string in your app.config refers to the local mdf file? perhaps it refers to the server instance?
What technology do you use, is it LinqToSql or Entity Framework (I think you have t call SaveChanges, not AcceptChanges)?
If you do intend to access the server instance, then the problem seems to be a security restriction.
Please add more details on statement no. 1, and I'll write further info.

SQL SERVER 2005 Automatic Schedule Backup Working not Properly

I am having a web server with install of WINDOWS 2003 Server and SQL SERVER 2005 Currently and i try to do a job schedule with the use of some control that i created. every thing is working properly but when it starts the job (in job i have written T-SQL Command for Backup Database) it will gives following error. i already check that i got the root directory path. and i have all the permission on that folder and i am as a DBOWNER of my database. but still i got error if any one or any person having idea regarding my error please help me immideately. please
****I am here gives path that is root directory of my Application ok****
MY ERROR :
Cannot open backup device 'C:\Inetpub\httpdocs\Full_BackUp_at21032009_092140AM.bak'. Device error or device off-line. See the SQL Server error log for more details. BACKUP DATABASE is terminating abnormally.
So, Please Help me if you having any ideas regarding why this error cause then if u wish to send solution directly me on this mail id : divyeshnh#gmail.com
Thank you
Sorry But I have whole rights that i wants at the root directory because i save my image files into this directory . so, you can understand that i have the rights.
Thank you for reply
i also do another thing :
i read yr answer very carefully & study all the things that u previously say. after that i try another thing that is i place that code on one button click event and fortunately i got success. so, i ask you when i try to do with schedule it will raised me an error while i click on button & take backup it will work fine. so, please give me answer about this.
Thank you for your reply
Thanks
Do the accounts used by SQL Server and Agent services have permissions to access the C:\Inetpub\httpdocs folder?
Are all the folders you your path already created? I think they have to already exist or you'll get an error.

Categories

Resources