Showing posts with label object. Show all posts
Showing posts with label object. Show all posts

Thursday, March 29, 2012

Error From Maintenance Plan

I am getting the following error in my Maintenance Plan. It looks as
if it is just one table (according to the Object id). My question is
how do I determine which table this is when all I have is this Object
ID?
Mark
[7] Database pcms: Check Data and Index Linkage...
[Microsoft SQL-DMO (ODBC SQLState: 42000)] Error 2576:
[Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
pointed to by the previous pointer of IAM page (1:28607) object ID
507864876 index ID 2 but was not detected in the scan.
The following errors were found:
[Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
pointed to by the previous pointer of IAM page (1:28607) object ID
507864876 index ID 2 but was not detected in the scan.
[Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
pointed to by the previous pointer of IAM page (1:96558) object ID
507864876 index ID 9 but was not detected in the scan.
[Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
pointed to by the previous pointer of IAM page (1:97687) object ID
507864876 index ID 10 but was not detected in the scan.
[Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
pointed to by the previous pointer of IAM page (1:111104) object ID
507864876 index ID 11 but was not detected in the scan.
[Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
pointed to by the previous pointer of IAM page (1:117681) object ID
507864876 index ID 12 but was not detected in the scan.
[Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
pointed to by the previous pointer of IAM page (1:117690) object ID
507864876 index ID 13 but was not detected in the scan.
[Microsoft][ODBC SQL Server Driver][SQL Server] The repair
level on the DBCC statement caused this repair to be bypassed.
[Microsoft][ODBC SQL Server Driver][SQL Server] The repair
level on the DBCC statement caused this repair to be bypassed.
[Microsoft][ODBC SQL Server Driver][SQL Server] The repair
level on the DBCC statement caused this repair to be bypassed.
[Microsoft][ODBC SQL Server Driver][SQL Server] The repair
level on the DBCC statement caused this repair to be bypassed.
[Microsoft][ODBC SQL Server Driver][SQL Server] The repair
level on the DBCC statement caused this repair to be bypassed.
[Microsoft][ODBC SQL Server Driver][SQL Server] The repair
level on the DBCC statement caused this repair to be bypassed.
[Microsoft][ODBC SQL Server Driver][SQL Server]CHECKDB found 12
allocation errors and 0 consistency errors in table '(Object ID
507864876)' (object ID 507864876).
[Microsoft][ODBC SQL Server Driver][SQL Server]CHECKDB found 12
allocation errors and 0 consistency errors in database 'pcms'.
[Microsoft][ODBC SQL Server Driver][SQL Server]repair_allow_data_loss
is the minimum repair level for the errors found by DBCC CHECKDB (pcms
repair_fast).
** Execution Time: 0 hrs, 2 mins, 22 secs **Hi Mark,
As all the indexes are non clustered (their indid is greater than 1) you
should be able to solve this issue by rebuilding the indexes on your table.
You can find the name of the table that is affected with
OBJECT_NAME(507864876), and you can then rebuild the indexes with DBCC
DBREINDEX(<table name>). Make a backup of your database first though.
--
Jacco Schalkwijk
SQL Server MVP
"Mark" <markcash@.Hotmail.com> wrote in message
news:57bdc737.0402160616.508ce27f@.posting.google.com...
> I am getting the following error in my Maintenance Plan. It looks as
> if it is just one table (according to the Object id). My question is
> how do I determine which table this is when all I have is this Object
> ID?
> Mark
>
> [7] Database pcms: Check Data and Index Linkage...
> [Microsoft SQL-DMO (ODBC SQLState: 42000)] Error 2576:
> [Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
> pointed to by the previous pointer of IAM page (1:28607) object ID
> 507864876 index ID 2 but was not detected in the scan.
> The following errors were found:
> [Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
> pointed to by the previous pointer of IAM page (1:28607) object ID
> 507864876 index ID 2 but was not detected in the scan.
> [Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
> pointed to by the previous pointer of IAM page (1:96558) object ID
> 507864876 index ID 9 but was not detected in the scan.
> [Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
> pointed to by the previous pointer of IAM page (1:97687) object ID
> 507864876 index ID 10 but was not detected in the scan.
> [Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
> pointed to by the previous pointer of IAM page (1:111104) object ID
> 507864876 index ID 11 but was not detected in the scan.
> [Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
> pointed to by the previous pointer of IAM page (1:117681) object ID
> 507864876 index ID 12 but was not detected in the scan.
> [Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
> pointed to by the previous pointer of IAM page (1:117690) object ID
> 507864876 index ID 13 but was not detected in the scan.
> [Microsoft][ODBC SQL Server Driver][SQL Server] The repair
> level on the DBCC statement caused this repair to be bypassed.
> [Microsoft][ODBC SQL Server Driver][SQL Server] The repair
> level on the DBCC statement caused this repair to be bypassed.
> [Microsoft][ODBC SQL Server Driver][SQL Server] The repair
> level on the DBCC statement caused this repair to be bypassed.
> [Microsoft][ODBC SQL Server Driver][SQL Server] The repair
> level on the DBCC statement caused this repair to be bypassed.
> [Microsoft][ODBC SQL Server Driver][SQL Server] The repair
> level on the DBCC statement caused this repair to be bypassed.
> [Microsoft][ODBC SQL Server Driver][SQL Server] The repair
> level on the DBCC statement caused this repair to be bypassed.
> [Microsoft][ODBC SQL Server Driver][SQL Server]CHECKDB found 12
> allocation errors and 0 consistency errors in table '(Object ID
> 507864876)' (object ID 507864876).
> [Microsoft][ODBC SQL Server Driver][SQL Server]CHECKDB found 12
> allocation errors and 0 consistency errors in database 'pcms'.
> [Microsoft][ODBC SQL Server Driver][SQL Server]repair_allow_data_loss
> is the minimum repair level for the errors found by DBCC CHECKDB (pcms
> repair_fast).
> ** Execution Time: 0 hrs, 2 mins, 22 secs **

Error From Maintenance Plan

I am getting the following error in my Maintenance Plan. It looks as
if it is just one table (according to the Object id). My question is
how do I determine which table this is when all I have is this Object
ID?
Mark
[7] Database pcms: Check Data and Index Linkage...
[Microsoft SQL-DMO (ODBC SQLState: 42000)] Error 2576:
[Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
pointed to by the previous pointer of IAM page (1:28607) object ID
507864876 index ID 2 but was not detected in the scan.
The following errors were found:
[Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
pointed to by the previous pointer of IAM page (1:28607) object ID
507864876 index ID 2 but was not detected in the scan.
[Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
pointed to by the previous pointer of IAM page (1:96558) object ID
507864876 index ID 9 but was not detected in the scan.
[Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
pointed to by the previous pointer of IAM page (1:97687) object ID
507864876 index ID 10 but was not detected in the scan.
[Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
pointed to by the previous pointer of IAM page (1:111104) object ID
507864876 index ID 11 but was not detected in the scan.
[Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
pointed to by the previous pointer of IAM page (1:117681) object ID
507864876 index ID 12 but was not detected in the scan.
[Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
pointed to by the previous pointer of IAM page (1:117690) object ID
507864876 index ID 13 but was not detected in the scan.
[Microsoft][ODBC SQL Server Driver][SQL Server] The repair
level on the DBCC statement caused this repair to be bypassed.
[Microsoft][ODBC SQL Server Driver][SQL Server] The repair
level on the DBCC statement caused this repair to be bypassed.
[Microsoft][ODBC SQL Server Driver][SQL Server] The repair
level on the DBCC statement caused this repair to be bypassed.
[Microsoft][ODBC SQL Server Driver][SQL Server] The repair
level on the DBCC statement caused this repair to be bypassed.
[Microsoft][ODBC SQL Server Driver][SQL Server] The repair
level on the DBCC statement caused this repair to be bypassed.
[Microsoft][ODBC SQL Server Driver][SQL Server] The repair
level on the DBCC statement caused this repair to be bypassed.
[Microsoft][ODBC SQL Server Driver][SQL Server]CHECKDB found 12
allocation errors and 0 consistency errors in table '(Object ID
507864876)' (object ID 507864876).
[Microsoft][ODBC SQL Server Driver][SQL Server]CHECKDB found 12
allocation errors and 0 consistency errors in database 'pcms'.
[Microsoft][ODBC SQL Server Driver][SQL Server]repair_allow_data_loss
is the minimum repair level for the errors found by DBCC CHECKDB (pcms
repair_fast).
** Execution Time: 0 hrs, 2 mins, 22 secs **Hi Mark,
As all the indexes are non clustered (their indid is greater than 1) you
should be able to solve this issue by rebuilding the indexes on your table.
You can find the name of the table that is affected with
OBJECT_NAME(507864876), and you can then rebuild the indexes with DBCC
DBREINDEX(<table name> ). Make a backup of your database first though.
Jacco Schalkwijk
SQL Server MVP
"Mark" <markcash@.Hotmail.com> wrote in message
news:57bdc737.0402160616.508ce27f@.posting.google.com...
> I am getting the following error in my Maintenance Plan. It looks as
> if it is just one table (according to the Object id). My question is
> how do I determine which table this is when all I have is this Object
> ID?
> Mark
>
> [7] Database pcms: Check Data and Index Linkage...
> [Microsoft SQL-DMO (ODBC SQLState: 42000)] Error 2576:
> [Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
> pointed to by the previous pointer of IAM page (1:28607) object ID
> 507864876 index ID 2 but was not detected in the scan.
> The following errors were found:
> [Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
> pointed to by the previous pointer of IAM page (1:28607) object ID
> 507864876 index ID 2 but was not detected in the scan.
> [Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
> pointed to by the previous pointer of IAM page (1:96558) object ID
> 507864876 index ID 9 but was not detected in the scan.
> [Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
> pointed to by the previous pointer of IAM page (1:97687) object ID
> 507864876 index ID 10 but was not detected in the scan.
> [Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
> pointed to by the previous pointer of IAM page (1:111104) object ID
> 507864876 index ID 11 but was not detected in the scan.
> [Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
> pointed to by the previous pointer of IAM page (1:117681) object ID
> 507864876 index ID 12 but was not detected in the scan.
> [Microsoft][ODBC SQL Server Driver][SQL Server]IAM page (0:0) is
> pointed to by the previous pointer of IAM page (1:117690) object ID
> 507864876 index ID 13 but was not detected in the scan.
> [Microsoft][ODBC SQL Server Driver][SQL Server] The repair
> level on the DBCC statement caused this repair to be bypassed.
> [Microsoft][ODBC SQL Server Driver][SQL Server] The repair
> level on the DBCC statement caused this repair to be bypassed.
> [Microsoft][ODBC SQL Server Driver][SQL Server] The repair
> level on the DBCC statement caused this repair to be bypassed.
> [Microsoft][ODBC SQL Server Driver][SQL Server] The repair
> level on the DBCC statement caused this repair to be bypassed.
> [Microsoft][ODBC SQL Server Driver][SQL Server] The repair
> level on the DBCC statement caused this repair to be bypassed.
> [Microsoft][ODBC SQL Server Driver][SQL Server] The repair
> level on the DBCC statement caused this repair to be bypassed.
> [Microsoft][ODBC SQL Server Driver][SQL Server]CHECKDB found 12
> allocation errors and 0 consistency errors in table '(Object ID
> 507864876)' (object ID 507864876).
> [Microsoft][ODBC SQL Server Driver][SQL Server]CHECKDB found 12
> allocation errors and 0 consistency errors in database 'pcms'.
> [Microsoft][ODBC SQL Server Driver][SQL Server]repair_allow_data_loss
> is the minimum repair level for the errors found by DBCC CHECKDB (pcms
> repair_fast).
> ** Execution Time: 0 hrs, 2 mins, 22 secs **

Error exporting to Excel with expression in footer

I can export to all other formats from the report viewer with no issues, but when I try to render to Excel, I get an exception:

[Exception: Object reference not set to an instance of an object.]

[Exception: An error occurred during rendering of the report.]

[Exception: An error occurred during rendering of the report.]
Microsoft.Reporting.WebForms.ServerReport.ServerUrlRequest(Boolean isAbortable, String url, Stream outputStream, String& mimeType, String& fileNameExtension) +553
Microsoft.Reporting.WebForms.ServerReport.InternalRender(Boolean isAbortable, String format, String deviceInfo, NameValueCollection urlAccessParameters, Stream reportStream, String& mimeType, String& fileNameExtension) +941
Microsoft.Reporting.WebForms.ServerReport.Render(String format, String deviceInfo, NameValueCollection urlAccessParameters, String& mimeType, String& fileNameExtension) +97
Microsoft.Reporting.WebForms.ServerReportControlSource.RenderReport(String format, String deviceInfo, NameValueCollection additionalParams, String& mimeType, String& fileExtension) +126
Microsoft.Reporting.WebForms.ExportOperation.PerformOperation(NameValueCollection urlQuery, HttpResponse response) +153
Microsoft.Reporting.WebForms.HttpHandler.ProcessRequest(HttpContext context) +202
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +154
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64

I've pinned it down to a footer cell that uses an expression to determine the TextAlign property. If I do something as simple as ="Right", I get the error. Of course, if I just use Right, there is no problem. So are expressions not supported in footer cell properties or is there possibly some fix for this?

Thanks.

The only solution would be to keep the textbox in the report body than the footer.

Shyam

|||

How can I get text to act like a page footer in the report body?

In case any MS folks are reading and want to reproduce this problem, here's a simple report that exhibits the behavior:

Code Snippet

<?xml version="1.0" encoding="utf-8"?>

<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">

<BottomMargin>1in</BottomMargin>

<RightMargin>1in</RightMargin>

<rd:DrawGrid>true</rd:DrawGrid>

<InteractiveWidth>8.5in</InteractiveWidth>

<rd:SnapToGrid>true</rd:SnapToGrid>

<Body>

<Height>0.79in</Height>

</Body>

<rd:ReportID>503a3ed2-a87d-4315-8de8-77c3ff0e807f</rd:ReportID>

<LeftMargin>1in</LeftMargin>

<Width>5in</Width>

<InteractiveHeight>11in</InteractiveHeight>

<Language>en-US</Language>

<PageFooter>

<ReportItems>

<Textbox Name="textbox3">

<Top>0.125in</Top>

<rd:DefaultName>textbox3</rd:DefaultName>

<Style>

<TextAlign>=IIf(Globals!PageNumber Mod 2 = 0, "Left", "Right")</TextAlign>

<PaddingLeft>2pt</PaddingLeft>

<PaddingBottom>2pt</PaddingBottom>

<PaddingRight>2pt</PaddingRight>

<PaddingTop>2pt</PaddingTop>

</Style>

<CanGrow>true</CanGrow>

<Value>Test</Value>

</Textbox>

</ReportItems>

<Height>0.375in</Height>

<PrintOnLastPage>true</PrintOnLastPage>

<PrintOnFirstPage>true</PrintOnFirstPage>

</PageFooter>

<TopMargin>1in</TopMargin>

</Report>

|||

Try to handle in the value property of the textbox. For example:

IIf(Globals!PageNumber Mod 2 = 0, CStr(Globals!PageNumber) & Space(15), Space(15) & CStr(Globals!PageNumber))

Shyam

Error exporting to Excel with expression in footer

I can export to all other formats from the report viewer with no issues, but when I try to render to Excel, I get an exception:

[Exception: Object reference not set to an instance of an object.]

[Exception: An error occurred during rendering of the report.]

[Exception: An error occurred during rendering of the report.]
Microsoft.Reporting.WebForms.ServerReport.ServerUrlRequest(Boolean isAbortable, String url, Stream outputStream, String& mimeType, String& fileNameExtension) +553
Microsoft.Reporting.WebForms.ServerReport.InternalRender(Boolean isAbortable, String format, String deviceInfo, NameValueCollection urlAccessParameters, Stream reportStream, String& mimeType, String& fileNameExtension) +941
Microsoft.Reporting.WebForms.ServerReport.Render(String format, String deviceInfo, NameValueCollection urlAccessParameters, String& mimeType, String& fileNameExtension) +97
Microsoft.Reporting.WebForms.ServerReportControlSource.RenderReport(String format, String deviceInfo, NameValueCollection additionalParams, String& mimeType, String& fileExtension) +126
Microsoft.Reporting.WebForms.ExportOperation.PerformOperation(NameValueCollection urlQuery, HttpResponse response) +153
Microsoft.Reporting.WebForms.HttpHandler.ProcessRequest(HttpContext context) +202
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +154
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64

I've pinned it down to a footer cell that uses an expression to determine the TextAlign property. If I do something as simple as ="Right", I get the error. Of course, if I just use Right, there is no problem. So are expressions not supported in footer cell properties or is there possibly some fix for this?

Thanks.

The only solution would be to keep the textbox in the report body than the footer.

Shyam

|||

How can I get text to act like a page footer in the report body?

In case any MS folks are reading and want to reproduce this problem, here's a simple report that exhibits the behavior:

Code Snippet

<?xml version="1.0" encoding="utf-8"?>

<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">

<BottomMargin>1in</BottomMargin>

<RightMargin>1in</RightMargin>

<rd:DrawGrid>true</rd:DrawGrid>

<InteractiveWidth>8.5in</InteractiveWidth>

<rd:SnapToGrid>true</rd:SnapToGrid>

<Body>

<Height>0.79in</Height>

</Body>

<rd:ReportID>503a3ed2-a87d-4315-8de8-77c3ff0e807f</rd:ReportID>

<LeftMargin>1in</LeftMargin>

<Width>5in</Width>

<InteractiveHeight>11in</InteractiveHeight>

<Language>en-US</Language>

<PageFooter>

<ReportItems>

<Textbox Name="textbox3">

<Top>0.125in</Top>

<rd:DefaultName>textbox3</rd:DefaultName>

<Style>

<TextAlign>=IIf(Globals!PageNumber Mod 2 = 0, "Left", "Right")</TextAlign>

<PaddingLeft>2pt</PaddingLeft>

<PaddingBottom>2pt</PaddingBottom>

<PaddingRight>2pt</PaddingRight>

<PaddingTop>2pt</PaddingTop>

</Style>

<CanGrow>true</CanGrow>

<Value>Test</Value>

</Textbox>

</ReportItems>

<Height>0.375in</Height>

<PrintOnLastPage>true</PrintOnLastPage>

<PrintOnFirstPage>true</PrintOnFirstPage>

</PageFooter>

<TopMargin>1in</TopMargin>

</Report>

|||

Try to handle in the value property of the textbox. For example:

IIf(Globals!PageNumber Mod 2 = 0, CStr(Globals!PageNumber) & Space(15), Space(15) & CStr(Globals!PageNumber))

Shyam

Error Expanding tables in Linked Server to Pervasive

Pleeeease help? I get an error when expanding the Tables object under linked servers in Enterprise Manager on a MSSQL2000 server.

I have a standard install of the Pervasive.SQL V8 data engine and DemoData db on my local PC. The SQL Server is also on my local PC.

I manage to create the Linked Server using the MSSQL Enterprise Manager. I used the following configuration:

Provider Name: Pervasive.SQL V8 OLE DB Provider
Product Name: Pervasive.SQL V8
Data source: DemoData
Provider string: <blank>
Location: workstation03
Catalog: <blank>

However when I try to expand the tables object under Linked Servers in the Enterprise manager I get the following error.

Error 7311: Could not obtain the schema rowset for the OLE DB provider 'UNKNOWN'. The provider supports the interface, but retuns a failure code when it is used. OLE DB error trace [OLE/DB Provider 'UNKNOWN' IDBSchemaRowset::GetRowset returned 0x80040155 ].

How would I fix this?

Thank you.moving to microsoft sql server forumsql

Monday, March 26, 2012

Error during installation process

Microsoft SQL Server 2005 Setup
-


The setup failed to get IID_IIMSAdminBase object. The error code is -2147467262.

Hi there,

I have checked every possible site for this error but unable to find any solution. I received the above alert message during the installation of SQL2k5, Reporting Services. I am using window xp with sp2.

When click OK to alert box then it rollback all installed components of Reporting Services.

Please help.

Cheers,

Zafar.

I believe you have a typo on the error message you have listed. I believe it actually states that it can not find the IIS Imsadminbase. This is the metabase (http://msdn2.microsoft.com/en-us/library/ms525941.aspx). I would remove IIS and then add it back and try the SSRS installation again.

Larry

Thursday, March 22, 2012

Error detaching sql express database using SMO

I am using SMO to provide a backup/restore feature. The restore code looks like this:

try
{
// Initialise server object.
Server server = new Server(serverName);
server.ConnectionContext.ConnectionString = connectionString;

// Check if database is current attached to sqlexpress.
foreach (Database db in server.Databases)
{
if (String.Compare(db.Name, destinationPath, true) == 0)
{
Console.WriteLine("Detaching existing database before restore ...");
server.DetachDatabase(db.Name, false);

break;
}
}

// Configure restore.
Restore restore = new Restore();
restore.Database = destinationPath;
restore.ReplaceDatabase = true;
restore.Action = RestoreActionType.Database;
restore.Devices.Add(new BackupDeviceItem(sourcePath, DeviceType.File));

// Perform restore.
restore.SqlRestore(server);
}
catch (FailedOperationException foe)
{
Console.WriteLine("Exception - SqlRestore of {0} failed with: {1}. Detail: {2}",
sourcePath, foe.Message, foe.InnerException.ToString());
}

This work 9/10 times. However occassional the DetachDatabase() call fails with the following error even though the database is not currently in use.

Exception - SqlRestore of D:\ImlDev\Auction\Auction\bin\Debug\Databases\databaseTest.bak failed with: Detach database failed for Server 'NICKDEV\SQLEXPRESS'. . Detail: Microsoft.SqlServer.Management.Common.ExecutionFailureException: An exception occurred while executing a Transact-SQL statement or batch. > System.Data.SqlClient.SqlException: Cannot detach the database 'D:\ImlDev\Auction\Auction\bin\Debug\Databases\databaseTest.mdf' because it is currently in use.

Clearly it was in use previously and the application using it may have crashed and not closed connections etc; this is why I want to restore the database.

How can I avoid/ workaround this to ensure my restore functionality is full proof.

Thanks,

Nick

Hello

I had exactly the same problem. It took some time to figure out but here is the solution:

You need to insert the restore code somewhere in your program before you open any database associated with your program. I put a restore databases button on the main form before any databases were opened. This works fine. Backup works wherever you put it in the code.

The reason for the problem is that once your database has been opened SQL Server will report an open connection even if you close the database connection. A gift from microsoft!!! There is no way you can disconnect from the database once you have opened it except to completely exit the program! Microsoft seems to provide thousands of options but never the one you need.

I hope this helps you.

|||

Hi,

I have just tackled the same problem, and I found using server.KillAllProcess(dbName) did the trick for me.

Nick

|||

You need to make sure you have the only connection to the database. You can do this by setting the database into single-user mode before detaching it, like this:

server.KillAllProcesses(db.Name);

db.DatabaseOptions.UserAccess = DatabaseUserAccess.Single;

db.Alter(TerminationClause.RollbackTransactionsImmediately);

server.DetachDatabase(db.Name, true);

Hope this helps,
Steve

|||Hi,

where exactly did you put your restore-code? On my MainForm, there's also a button, so I think it will be initialized before any connections are opened in MainForm_Load. In the button's click event I call the method that includes the "detach" code. But I receive the same error that the database is in use.

MusiMeli

Error detaching sql express database using SMO

I am using SMO to provide a backup/restore feature. The restore code looks like this:

try
{
// Initialise server object.
Server server = new Server(serverName);
server.ConnectionContext.ConnectionString = connectionString;

// Check if database is current attached to sqlexpress.
foreach (Database db in server.Databases)
{
if (String.Compare(db.Name, destinationPath, true) == 0)
{
Console.WriteLine("Detaching existing database before restore ...");
server.DetachDatabase(db.Name, false);

break;
}
}

// Configure restore.
Restore restore = new Restore();
restore.Database = destinationPath;
restore.ReplaceDatabase = true;
restore.Action = RestoreActionType.Database;
restore.Devices.Add(new BackupDeviceItem(sourcePath, DeviceType.File));

// Perform restore.
restore.SqlRestore(server);
}
catch (FailedOperationException foe)
{
Console.WriteLine("Exception - SqlRestore of {0} failed with: {1}. Detail: {2}",
sourcePath, foe.Message, foe.InnerException.ToString());
}

This work 9/10 times. However occassional the DetachDatabase() call fails with the following error even though the database is not currently in use.

Exception - SqlRestore of D:\ImlDev\Auction\Auction\bin\Debug\Databases\databaseTest.bak failed with: Detach database failed for Server 'NICKDEV\SQLEXPRESS'. . Detail: Microsoft.SqlServer.Management.Common.ExecutionFailureException: An exception occurred while executing a Transact-SQL statement or batch. > System.Data.SqlClient.SqlException: Cannot detach the database 'D:\ImlDev\Auction\Auction\bin\Debug\Databases\databaseTest.mdf' because it is currently in use.

Clearly it was in use previously and the application using it may have crashed and not closed connections etc; this is why I want to restore the database.

How can I avoid/ workaround this to ensure my restore functionality is full proof.

Thanks,

Nick

Hello

I had exactly the same problem. It took some time to figure out but here is the solution:

You need to insert the restore code somewhere in your program before you open any database associated with your program. I put a restore databases button on the main form before any databases were opened. This works fine. Backup works wherever you put it in the code.

The reason for the problem is that once your database has been opened SQL Server will report an open connection even if you close the database connection. A gift from microsoft!!! There is no way you can disconnect from the database once you have opened it except to completely exit the program! Microsoft seems to provide thousands of options but never the one you need.

I hope this helps you.

|||

Hi,

I have just tackled the same problem, and I found using server.KillAllProcess(dbName) did the trick for me.

Nick

|||

You need to make sure you have the only connection to the database. You can do this by setting the database into single-user mode before detaching it, like this:

server.KillAllProcesses(db.Name);

db.DatabaseOptions.UserAccess = DatabaseUserAccess.Single;

db.Alter(TerminationClause.RollbackTransactionsImmediately);

server.DetachDatabase(db.Name, true);

Hope this helps,
Steve

|||Hi,

where exactly did you put your restore-code? On my MainForm, there's also a button, so I think it will be initialized before any connections are opened in MainForm_Load. In the button's click event I call the method that includes the "detach" code. But I receive the same error that the database is in use.

MusiMeli

Error detaching sql express database using SMO

I am using SMO to provide a backup/restore feature. The restore code looks like this:

try
{
// Initialise server object.
Server server = new Server(serverName);
server.ConnectionContext.ConnectionString = connectionString;

// Check if database is current attached to sqlexpress.
foreach (Database db in server.Databases)
{
if (String.Compare(db.Name, destinationPath, true) == 0)
{
Console.WriteLine("Detaching existing database before restore ...");
server.DetachDatabase(db.Name, false);

break;
}
}

// Configure restore.
Restore restore = new Restore();
restore.Database = destinationPath;
restore.ReplaceDatabase = true;
restore.Action = RestoreActionType.Database;
restore.Devices.Add(new BackupDeviceItem(sourcePath, DeviceType.File));

// Perform restore.
restore.SqlRestore(server);
}
catch (FailedOperationException foe)
{
Console.WriteLine("Exception - SqlRestore of {0} failed with: {1}. Detail: {2}",
sourcePath, foe.Message, foe.InnerException.ToString());
}

This work 9/10 times. However occassional the DetachDatabase() call fails with the following error even though the database is not currently in use.

Exception - SqlRestore of D:\ImlDev\Auction\Auction\bin\Debug\Databases\databaseTest.bak failed with: Detach database failed for Server 'NICKDEV\SQLEXPRESS'. . Detail: Microsoft.SqlServer.Management.Common.ExecutionFailureException: An exception occurred while executing a Transact-SQL statement or batch. > System.Data.SqlClient.SqlException: Cannot detach the database 'D:\ImlDev\Auction\Auction\bin\Debug\Databases\databaseTest.mdf' because it is currently in use.

Clearly it was in use previously and the application using it may have crashed and not closed connections etc; this is why I want to restore the database.

How can I avoid/ workaround this to ensure my restore functionality is full proof.

Thanks,

Nick

Hello

I had exactly the same problem. It took some time to figure out but here is the solution:

You need to insert the restore code somewhere in your program before you open any database associated with your program. I put a restore databases button on the main form before any databases were opened. This works fine. Backup works wherever you put it in the code.

The reason for the problem is that once your database has been opened SQL Server will report an open connection even if you close the database connection. A gift from microsoft!!! There is no way you can disconnect from the database once you have opened it except to completely exit the program! Microsoft seems to provide thousands of options but never the one you need.

I hope this helps you.

|||

Hi,

I have just tackled the same problem, and I found using server.KillAllProcess(dbName) did the trick for me.

Nick

|||

You need to make sure you have the only connection to the database. You can do this by setting the database into single-user mode before detaching it, like this:

server.KillAllProcesses(db.Name);

db.DatabaseOptions.UserAccess = DatabaseUserAccess.Single;

db.Alter(TerminationClause.RollbackTransactionsImmediately);

server.DetachDatabase(db.Name, true);

Hope this helps,
Steve

|||Hi,

where exactly did you put your restore-code? On my MainForm, there's also a button, so I think it will be initialized before any connections are opened in MainForm_Load. In the button's click event I call the method that includes the "detach" code. But I receive the same error that the database is in use.

MusiMeli
sql

Error detaching sql express database using SMO

I am using SMO to provide a backup/restore feature. The restore code looks like this:

try
{
// Initialise server object.
Server server = new Server(serverName);
server.ConnectionContext.ConnectionString = connectionString;

// Check if database is current attached to sqlexpress.
foreach (Database db in server.Databases)
{
if (String.Compare(db.Name, destinationPath, true) == 0)
{
Console.WriteLine("Detaching existing database before restore ...");
server.DetachDatabase(db.Name, false);

break;
}
}

// Configure restore.
Restore restore = new Restore();
restore.Database = destinationPath;
restore.ReplaceDatabase = true;
restore.Action = RestoreActionType.Database;
restore.Devices.Add(new BackupDeviceItem(sourcePath, DeviceType.File));

// Perform restore.
restore.SqlRestore(server);
}
catch (FailedOperationException foe)
{
Console.WriteLine("Exception - SqlRestore of {0} failed with: {1}. Detail: {2}",
sourcePath, foe.Message, foe.InnerException.ToString());
}

This work 9/10 times. However occassional the DetachDatabase() call fails with the following error even though the database is not currently in use.

Exception - SqlRestore of D:\ImlDev\Auction\Auction\bin\Debug\Databases\databaseTest.bak failed with: Detach database failed for Server 'NICKDEV\SQLEXPRESS'. . Detail: Microsoft.SqlServer.Management.Common.ExecutionFailureException: An exception occurred while executing a Transact-SQL statement or batch. > System.Data.SqlClient.SqlException: Cannot detach the database 'D:\ImlDev\Auction\Auction\bin\Debug\Databases\databaseTest.mdf' because it is currently in use.

Clearly it was in use previously and the application using it may have crashed and not closed connections etc; this is why I want to restore the database.

How can I avoid/ workaround this to ensure my restore functionality is full proof.

Thanks,

Nick

Hello

I had exactly the same problem. It took some time to figure out but here is the solution:

You need to insert the restore code somewhere in your program before you open any database associated with your program. I put a restore databases button on the main form before any databases were opened. This works fine. Backup works wherever you put it in the code.

The reason for the problem is that once your database has been opened SQL Server will report an open connection even if you close the database connection. A gift from microsoft!!! There is no way you can disconnect from the database once you have opened it except to completely exit the program! Microsoft seems to provide thousands of options but never the one you need.

I hope this helps you.

|||

Hi,

I have just tackled the same problem, and I found using server.KillAllProcess(dbName) did the trick for me.

Nick

|||

You need to make sure you have the only connection to the database. You can do this by setting the database into single-user mode before detaching it, like this:

server.KillAllProcesses(db.Name);

db.DatabaseOptions.UserAccess = DatabaseUserAccess.Single;

db.Alter(TerminationClause.RollbackTransactionsImmediately);

server.DetachDatabase(db.Name, true);

Hope this helps,
Steve

|||Hi,

where exactly did you put your restore-code? On my MainForm, there's also a button, so I think it will be initialized before any connections are opened in MainForm_Load. In the button's click event I call the method that includes the "detach" code. But I receive the same error that the database is in use.

MusiMeli

Wednesday, March 21, 2012

Error creating object SQL 7.0 using sp_oaCreate

Hi,
I am trying to troubleshoot an issue that came up suddenly on a SQL Server 7
that I support.
There is a sp that runs every five minutes and one of the functions in the
sp uses the sp_oaCreate to create and object which returns some free disk
space information. This sp has been working fine for over six years now and
all of a sudden, last w, it started failing. After some debugging, I foun
d
that the following call is failing with the attached error;
exec @.hr = sp_oaCreate 'CqDiskSpace.clsDiskSpace', @.ds OUTPUT
if @.hr <> 0
begin
set @.ErrMsg = 'Could not create CqDiskSpace.clsDiskSpace -- error ' +
cast(@.hr as varchar(15))
goto EH
end
And the error is:
Could not create CqDiskSpace.clsDiskSpace -- error -2147221164.
I've been searching google and other things and found some information on
this forum with a similar error but the odd thing is that it it was working
fine and there was nothing done to the system at that time.
I should mention that I can create the object from outside the stored
procedure with no problems. It is SQL Server 7.0 7.00.961.
Can anyone possibly point me in a direction of what to look for?
Thanks a bunchNever Mind,
Stopping and starting the SQL Server fixed the issue.
I should have started with that.
Thanks
"Ryan Gaudet" wrote:

> Hi,
> I am trying to troubleshoot an issue that came up suddenly on a SQL Server
7
> that I support.
> There is a sp that runs every five minutes and one of the functions in the
> sp uses the sp_oaCreate to create and object which returns some free disk
> space information. This sp has been working fine for over six years now an
d
> all of a sudden, last w, it started failing. After some debugging, I fo
und
> that the following call is failing with the attached error;
> exec @.hr = sp_oaCreate 'CqDiskSpace.clsDiskSpace', @.ds OUTPUT
> if @.hr <> 0
> begin
> set @.ErrMsg = 'Could not create CqDiskSpace.clsDiskSpace -- error ' +
> cast(@.hr as varchar(15))
> goto EH
> end
> And the error is:
> Could not create CqDiskSpace.clsDiskSpace -- error -2147221164.
> I've been searching google and other things and found some information on
> this forum with a similar error but the odd thing is that it it was workin
g
> fine and there was nothing done to the system at that time.
> I should mention that I can create the object from outside the stored
> procedure with no problems. It is SQL Server 7.0 7.00.961.
> Can anyone possibly point me in a direction of what to look for?
> Thanks a bunchsql

Monday, March 19, 2012

Error creating datasource

A user is getting an error "Cannot update, database or object is read-only"
when creating a datasource.
The user has db_owner role of the database that's being connected to.
I know very little of Analysis Server and any help would be appreciated.
Thanks.
RonThis is the typical error when two or more users are using SQL Analysis
Manager and the Olap repository is still in MS Access database, which it's
oppened in exclusive mode by Analysis Manager.
Try migrating Olap Repository to SQL Server and hopefully your problem is
gone.
Michael Prendergast
"Ron" <Ron@.discussions.microsoft.com> escribi en el mensaje
news:CC03234F-0585-41A7-8128-078EB865B5AA@.microsoft.com...
>A user is getting an error "Cannot update, database or object is read-only"
> when creating a datasource.
> The user has db_owner role of the database that's being connected to.
> I know very little of Analysis Server and any help would be appreciated.
> Thanks.
> Ron
>|||There's no Access involved - just SQL Server
Ron
"MPS" wrote:

> This is the typical error when two or more users are using SQL Analysis
> Manager and the Olap repository is still in MS Access database, which it's
> oppened in exclusive mode by Analysis Manager.
> Try migrating Olap Repository to SQL Server and hopefully your problem is
> gone.
> Michael Prendergast
>
> "Ron" <Ron@.discussions.microsoft.com> escribió en el mensaje
> news:CC03234F-0585-41A7-8128-078EB865B5AA@.microsoft.com...
>
>|||How do you migrate the OLAP Repository (Access) to a SQL Server?
"MPS" wrote:

> This is the typical error when two or more users are using SQL Analysis
> Manager and the Olap repository is still in MS Access database, which it's
> oppened in exclusive mode by Analysis Manager.
> Try migrating Olap Repository to SQL Server and hopefully your problem is
> gone.
> Michael Prendergast
>
> "Ron" <Ron@.discussions.microsoft.com> escribió en el mensaje
> news:CC03234F-0585-41A7-8128-078EB865B5AA@.microsoft.com...
>
>|||Open Analysis Manager, select the server name in the list (typically one),
right click over the server name and there you are, MIGRAR DEPOSITO in
Spanish, MIGRATE REPOSITORY I guess in English (I use Spanish version
You will need a DB created in SQL Server and connect to it with owner
privileges over that database
"Rodrigo" <Rodrigo@.discussions.microsoft.com> escribi en el mensaje
news:515C83DA-0157-4E12-9832-DAD3A18AC8E8@.microsoft.com...
> How do you migrate the OLAP Repository (Access) to a SQL Server?
>
> "MPS" wrote:
>
>|||Just in case, default installation for MS Analysis Services manages Olap
repository in an Access Database.
Probably you do not have any data in Access, but the repository, if is not
migrated yet, It's still in a MS Access Database. The file is named
msmdrep.mdb and has two tables, OlapObjects and Server.
Hope it helps,
Michael Prendergast
"Ron" <Ron@.discussions.microsoft.com> escribi en el mensaje
news:6DB504F8-F1CB-4EFB-A216-8A50909012E5@.microsoft.com...
> There's no Access involved - just SQL Server
> Ron
> "MPS" wrote:
>
>|||That did the trick - Thanks MPS.
"MPS" wrote:

> Just in case, default installation for MS Analysis Services manages Olap
> repository in an Access Database.
> Probably you do not have any data in Access, but the repository, if is not
> migrated yet, It's still in a MS Access Database. The file is named
> msmdrep.mdb and has two tables, OlapObjects and Server.
> Hope it helps,
> Michael Prendergast
> "Ron" <Ron@.discussions.microsoft.com> escribió en el mensaje
> news:6DB504F8-F1CB-4EFB-A216-8A50909012E5@.microsoft.com...
>
>|||Good to hear that
Michael Prendergast
"Ron" <Ron@.discussions.microsoft.com> escribi en el mensaje
news:0727D691-8903-4472-97BC-1A9F65508608@.microsoft.com...
> That did the trick - Thanks MPS.
> "MPS" wrote:
>
>