DBCC CheckDB
- 
				testiclesoup
 - Posts: 11
 - Joined: Mon 24 Dec 2012 04:46
 
DBCC CheckDB
I am trying to find a way to execute a dbcc checkdb command from within my application. I want to parse the results looking for issue that need to be addressed. What component would be appropriate and how can I get access to the results as they do not return a result set?
Thanks,
Kevin
			
									
									
						Thanks,
Kevin
- 
				AndreyZ
 
Re: DBCC CheckDB
Hello,
To execute the 'DBCC CHECKDB' statement, you should use the TMSQuery component. The results can be parsed in the TMSConnection.OnInfoMessage event handler. Here is a code example:Note that to run this code, you should add the OLEDBAccess unit to the USES clause of your unit.
			
									
									
						To execute the 'DBCC CHECKDB' statement, you should use the TMSQuery component. The results can be parsed in the TMSConnection.OnInfoMessage event handler. Here is a code example:
Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
begin
  MSQuery1.Connection := MSConnection1;
  MSQuery1.Execute;
end;
procedure TForm1.MSConnection1InfoMessage(Sender: TObject; E: EMSError);
begin
  Memo1.Lines.Add(E.Message);
end;- 
				testiclesoup
 - Posts: 11
 - Joined: Mon 24 Dec 2012 04:46
 
Re: DBCC CheckDB
Outstanding. It works very well.
Thanks for your help and thanks to the team for these are components.
			
									
									
						Thanks for your help and thanks to the team for these are components.
- 
				AndreyZ
 
Re: DBCC CheckDB
I am glad I could help. Feel free to contact us if you have any further questions about SDAC.
			
									
									
						- 
				testiclesoup
 - Posts: 11
 - Joined: Mon 24 Dec 2012 04:46
 
Re: DBCC CheckDB
I spoke a bit too soon. I got the first set of results just fine. But, when I try to run dbcc checkdb on a second database, the InfoMessage event doesn't fire. I have not yet been able to confirm that the second dbcc even happens. I have tried closing the query object before sending the new command to no avail. Is there something I need to do to make this work?
UnicodeString query("dbcc checkdb (");
query += pDatabases->Strings[0];
query += ")";
quMisc->Close();
quMisc->SQL->Clear();
quMisc->SQL->Add(query);
quMisc->Execute();
Thanks.
			
									
									
						UnicodeString query("dbcc checkdb (");
query += pDatabases->Strings[0];
query += ")";
quMisc->Close();
quMisc->SQL->Clear();
quMisc->SQL->Add(query);
quMisc->Execute();
Thanks.
- 
				AndreyZ
 
Re: DBCC CheckDB
I cannot reproduce the problem. I tried executing your code using SDAC 6.6.11 in C++Builder 2010, and there were no problems with its executing several times in a row for different databases. Please specify the following:
- the exact version of SDAC. You can learn it from the About sheet of TMSConnection Editor;
- the exact version of your IDE;
- the exact version of SQL Server server and client you are using. You can learn it from the Info sheet of TMSConnection Editor.
			
									
									
						- the exact version of SDAC. You can learn it from the About sheet of TMSConnection Editor;
- the exact version of your IDE;
- the exact version of SQL Server server and client you are using. You can learn it from the Info sheet of TMSConnection Editor.
- 
				testiclesoup
 - Posts: 11
 - Joined: Mon 24 Dec 2012 04:46
 
Re: DBCC CheckDB
SDAC version is 6.1.5.
Rad Studio XE2 version is 16.0.4429.46931.
Microsoft SQL Server: 09.00.4035
Microsoft SQL Native Client: 9.00.5000.00
			
									
									
						Rad Studio XE2 version is 16.0.4429.46931.
Microsoft SQL Server: 09.00.4035
Microsoft SQL Native Client: 9.00.5000.00
- 
				AndreyZ
 
Re: DBCC CheckDB
I still cannot reproduce the problem. Please try creating a small sample to demonstrate the problem and send it to andreyz*devart*com .
Also, you can try the following:
- unistall SDAC;
- update RAD Studio XE2 to version 16.0.4504.48759 (it is RAD Studio XE2 Update 4 with Hotfix 1);
- install SDAC 6.2.7 or higher.
After this, check if the problem persists in such environment.
			
									
									
						Also, you can try the following:
- unistall SDAC;
- update RAD Studio XE2 to version 16.0.4504.48759 (it is RAD Studio XE2 Update 4 with Hotfix 1);
- install SDAC 6.2.7 or higher.
After this, check if the problem persists in such environment.
- 
				testiclesoup
 - Posts: 11
 - Joined: Mon 24 Dec 2012 04:46
 
Re: DBCC CheckDB
I figured it out. I went ahead and updated to the latest XE2 hotfix and to the most recent version of your components. That didn't help. It turns out that the issue was this: I was trying to run the next scan from inside of the InfoMessage event. I moved the execution of this event and it works just fine. 
Thanks for your help.
Regards,
Kevin
			
									
									
						Thanks for your help.
Regards,
Kevin