.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Accessing database in STANDBY mode while log shipping

Posted By:      Posted Date: September 08, 2010    Points: 0   Category :Sql Server
Hi,     I am testing with Log shipping, I have it setup and it is working just fine. The secondary database was restored with Standby mode and is readonly. I have no problem accessing and querying data from the secondary database but I noticed if changes are made to the primary and I am accessing the database when the restore step to the secondary runs it fails with the following error: Message2006-07-31 09:40:54.33 *** Error: Could not apply log backup file 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\LogShip\CI_REPLICATION_TEST_20060731131501.trn' to secondary database 'CI_REPLICATION_TEST'.(Microsoft.SqlServer.Management.LogShipping) ***2006-07-31 09:40:54.33 *** Error: Exclusive access could not be obtained because the database is in use.RESTORE LOG is terminating abnormally.(.Net SqlClient Data Provider) *** This appears to be because you can not restore to a database that is in use? How do you get around this? Is it possible? How do I query data from the secondary db without worrying about causing log shipping to fail? Do I not worry about it because at somepoint when Exclusive access is obtainable all the logs will be rolled forward, but this could create a wide gap in sychronization between the primary and secondary db's, say if someone or something does not properly log off. I guess I could disconnect all users prior to applying tlogs but that kind

View Complete Post

More Related Resource Links

accessing values from a database with datalist?


I have a datalist and I am filling it using a dataadapter, dataset. So in my .ascx page, I have

<asp:datalist runat="server" id="dlProducts" repeatcolumns="2" repeatdirection="horizontal">


<table border="0">

<tr><td><%# Eval("Item_Name") %></td></tr>

<tr><td>I have to add a picture here</td><td><%# Eval("First_Name") %></td></tr>




In the area where I have put a statement like "I have to add a picture here", I have write a big case statement.  Like:

Case: 6 // show a picture from file1

case: 7 // show a picture from file2

Case 8: //show a picture from file3


So How do I do this here?  Because I dont know how to access the datalist values from code behind.


Here is my code behind:

SQLString = "SELECT First_Name, Picture, item_name, item_id from table1 where item_id = " + request.querystring["iid"];

dataadapter daItems = new dataadapter(SQLString, "connection_name");

dataset dsItems = new dataset();



replicate a standby / read-only database

I have a database that is being replicated with log shipping. The database is in Standby/Read-only mode. The logs are restored every 30 seconds. For the logs to be restored all users are disconnected. But I want to have continuous read access to the replicated database. So I thought: why not replicate the replicated database? This second replication can happen on the same machine or on the same instance, the only purpose would be having a copy for continuous read access. I have looked at mirroring and transactional replication, but these things do not give me what. Is there a way of replicating a Standby/Read-Only database with continous read access to the replica? Thanks in advance, Frans

My Sql server 2005 Database in recovery mode for 3 -4 hours every day

Hi , Some of our Sql Server 2005 databases remain in recovery mode after midnight for almost 3 to 4 hours. So when my application access them error "Databse in recovery" and for same database this happens again and again every night. Please suggest why and how this can be solved?

Accessing a row's dropdownlist values AFTER the gridview control is in Edit mode

Hello, I have a gridview control. When it goes into Edit mode, there are 3 dropdownlists in one cell that are populated by separate stored procedures during the RowDataBound event. The 1st dropdownlist's value is used as a parameter to determine what the 2nd dropdownlist is populated with. The 2nd dropdownlist's value is used as a parameter to determine what the 3rd dropdownlist is populated with. Everything works fine when the row is first put into Edit mode. While I'm in Edit mode and I change the selection in the 1st dropdownlist, how do I access the control so I can feed this new parameter to the 2nd dropdownlist? I have the first 2 dropdownlists set for AutoPostBack so that the Page_Load event is fired when the user changes a value. I know how to get access to these controls via the FindControl method when the row is being databound but how do I find the control during the Page_Load event? Thanks for any help!!!   Penny  

Accessing a database

I have added a folder called "Databse" in my application and inside that i have a databse file(SQL Databse named dbFiles), and my connection string looks like this : < add name="conString" connectionString="Data Source=localhost;database=dbFiles;Persist Security Info=True;"/> Now my problem is i am unable to open a connection to this database. What am i doing wrong????

SQL Server 2008 Windows Authentication Mode fails for Database Engine, error 18456

I installed SQL Server 2008 Developer Edition (10.0.1600.22.080709-1414) on a Windows Vista 32-bit development machine with Windows Authentication Mode only (no SQL Server Authentication).   Since this is a development machine, I saw no need for Mixed Mode when I did the install.  The SQL Server Management Studio allows me to login to Analysis Services, Integration Services, Reporting Services, BUT NOT the Database Engine!Windows Authentication for the Database Engine gives the following error: EventID: 18456Login failed for user MYDOMAIN\MYLOGIN'. Reason: Token-based server access validation failed with an infrastructure error. Check for previous errors. [CLIENT: <local machine>]The 'fix' I have found online is to login as SA in SQL Server Authentication mode & add MYDOMAIN\MYLOGIN as a administrator for the Database Engine.  Unfortunately, I can't since I didn't install SQL Server Authentication mode (only Windows Authentication Mode).  It appears my only recourse is to uninstall, then reinstall in Mixed mode, then to login as SA in SQL Server Authentication mode & add MYDOMAIN\MYLOGIN as a administrator for the Database Engine. Before I do so, does anyone know of a better approach?Scott D Duncan

MSSQL 2008 R2 - database in restoring mode after backup - forever..

Hi folks,   i have this problem that occourred today with one instance of MSSQL 2008 R2 running on a WIN x64 R2 enterprise server.   i have run a backup maintainance job and now i have two databases in restoring mode for over 4hrs.   my questions are: why are these databases restoring when i was backing up? and why are they not being logged anywhere - i can not find anything on logs, activty monitor, or even Windows Resource Monitor.   i can not see any work been done by MSSQL to restore these databases, and yet they are set as 'RESTORING'.   any suggestion from the community here will be much appreciated as i am banging my head against the wall already.   thanks,   Nicolas    data warehouse | data migration | ETL/ELT | UK | http://www.brainpowered.net

Database peaks CPU after recovery. Stuck in recovery mode

Rather simple problem. The database is stuck in recovery mode and I can't use it.. mssqlserver process want 100% CPU. I left it in recovery mode for almost a week with no luck. My idea was that it would repair itself. But it doesn't help and now I'm about to give up on that database. It seems quite odd that the last log entries in the ERRORLOG says: "Recovery complete..  phase 2 of 3" and then it says "Recovery 97% complete ..phase 3 of 3" After that, CPU peaks. Any ideas? Thank you! ERRORLOG: 2009-09-14 15:52:26.89 Server      Microsoft SQL Server 2005 - 9.00.4035.00 (Intel X86)     Nov 24 2008 13:01:59     Copyright (c) 1988-2005 Microsoft Corporation     Express Edition on Windows NT 5.2 (Build 3790: Service Pack 2) 2009-09-14 15:52:26.89 Server      (c) 2005 Microsoft Corporation. 2009-09-14 15:52:26.89 Server      All rights reserved. 2009-09-14 15:52:26.89 Server      Server process ID is 8860. 2009-09-14 15:52:26.89 Server      Authentication mode is WINDOWS-ONLY. 2009-09-14 15:52:26.89 Server      Logging SQL Server messages in file 'c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG'. 2009-09-14 15:52:26.89 Server      This instance of SQL Server last reported using a process ID of 7996 at 9/14/2009 3:15:48 PM (local) 9/14/2009 1:15:48 PM (UTC). This is an informational message only; no user action is required. 2009-0

Accessing the same database many people at once


I there.

 I made a website, 1 database;  We have 4 cumputers, the 4 are using the same website and saving datas at the SAME TIME.

 The problem that i have is that when 2 people click in the save button at the same time, only onces is in the database, but the others get lost.


 Visual Studio 2010, Framework 3.5, MS-SQL 2008, C#.

 The conecction is in c#, everthing is in c#.





Accessing my Web Application's database with MSSMS at the same time.



I wish to acces my database using MSSMS at the same time that I am running my web application. When I tried to access my database with MSSMS I get the following error:

Failed to retrieve data for this request (Microsoft.SqlServer. Management.SDk.Sfc)

Additional Information:

Unable to open the physical file "C:\inetpub\wwwroot\myapp\App_Data\aspnetdb.mdf".
Operationg system error 32: "32(The process cannot access the file because it is being used by another process)". (Microsoft SQL Server, Error:5120).

What can I do to being able to view my database with MSSMS at the same time?

Thanks for your help,


Accessing a .mdb database in 64 Bit Platform


I want to upgrade the 32bit application to 64 bit application.
In my 32 bit application i use Microsoft Access as the backend database ( simple only with some few tables, no relations)

I have used MFC database classes like CDaoDatabase, CDaoRecordset for accessing the database.
During the upgrading process i came to found that CDaoDatabase classes are now no longer supported in Win64 platforms.
I get the following error:
 fatal error C1189: #error :  DAO Database classes are not supported for Win64 platforms

Also going through some of msdn Q/A articles, i found that CDaoDatabase classes have been deprecated now, or sth like there is no provision for accessing the .mdb in X64 platform.

Is there really no method for accessing the Access database in X64 platform.
Are there any other solutions.....
Is switching to ADO.Net will be the solution....

Hope Somebody will put the light on this topic..

Anur RS..

Database goes to suspect mode


Hi Team,


Two days back i went one DBA interview he is asked some dba questions 


Q. we have 25 database in this one database is goes to suspect mode. How do you know x database is goes to suspect mode.


      i said we got one alert or mail x database is goes to suspect mode 


my be my answer is wrong could you any body please give me exact answer for this.


Q. we have 14 instances one instance is correpected or it goes to suspect mode how can we know x instance goes to suspect mode ?



Can you any body please guide me for this one.. i m bit confue on this my expectation instance could not goes to suspect mode right can you correct me.






Database Corrupted - Can't get db in single user mode

I have two SQL 2008 R2 databases running on a 64-bit development Machine :
I have created Synonyms in MyDatabase (Table1, Table2, Table3) for three tables in the IMS database.
I am experiencing very poor performance using these Synonyms from my application so I am trying to troubleshoot the problem.
I tried to run "DBCC CHECKDB (IMS,  REPAIR_ALLOW_DATA_LOSS)" by performing the following steps
  1. Used Services to stop the processes (Instance, Agent, Browser, Integration Services 10.0, VSS Writer)
  2. Ran cmd.exe "As Administrator"
  3. cd C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\Binn
  4. ran sqlservr.exe -m -s SQLEXPRESS (output says it started in single user mode)


  1. Ran cmd.exe "As Administrator"
  2. cd C:\Program Files\Microsoft SQL Server\100\Tools\Binn
  3. ran sqlcmd.exe -S D

RemoteApp - Terminal Services detect client going into standby mode



I have a RemoteApp running on the Terminal Server. Application is using a serial port. When client pc goes into standby mode everything is ok , I have a lot of problems when pc wakes up ( high CPU and memory usage ) . I was trying to prevent it but I can’t find any solution ( session remains active on the server ) . I decided maybe it would be good to try to detect moment when communication between client and server is interrupted and close application then. I had a look at WTS API but I can’t see anything meeting my requirements. Could some suggest some solution?

Thank you

Compatibility Mode change whilst log shipping



I have a database in compatibility mode 80 being log shipped from one SQL Server 2005 instance to another.  I want to change the compatibility mode on the database to 90, but was wondering what, if any, affect this would have on log shipping?  The database vendors have already confirmed that the database/application is compliant.

Thanks, Andy

database stuck in emergency mode error 952


Please help.  Database is stuck in emergency mode and cannot enter into single_user.  Please help!!

Dr. William Sewell

SQL Server 2000 Database in "single user mode"


Hi all,

I've an old production database server with SQL Server 2000 SP4, that runs from 6 years. Now sometimes I find that the production database goes in "single user mode". Why? My error logs don't help me.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend