Compact a Database in OLEDB - oledb

Does anyone know how to compact a SQL Server CE 4.0 database using OLEDB?
I can't seem to find any documentation on how to do this.
SQL Server CE does not support the DBCC SHRINKDATABASE command.

I am thinking you are looking for either Compact or autoshrink
http://technet.microsoft.com/en-us/library/ms174034.aspx
http://technet.microsoft.com/en-us/library/ms172411.aspx

Related

Microsoft Jet Database could not find Object

I am trying to Migrate my Software from Windows 2008r2 to Windows 2012.
I created using odbc32 the Datasource Hegla ( Version Paradox 5.x ) , the Network Directory was changed to c:\Database .
Then from Delphi I do the connection string like this :
Provider=MSDASQL.1;Persist Security Info=False;Data Source=Hegla;Mode=ReadWrite;Initial Catalog=C:\database\augustdorf\hegla-lager;
Then if I try to open the Query, i get the error : The Microsoft Jet Database engine could not find the object Glasdaten
The query itself looks like this
select ArtikelNr as RemoteArtNr,Name,Höhe as Hoehe,Breite,Staerke,Mindestmenge as Bestellbestand,
count(c2.Glaszaehler) as Bestand,c2.BockNr
from Glasdaten c1
left join Lagerdaten c2 on c1.Glaszaehler=c2.Glaszaehler
group by ArtikelNr,Name,Höhe,Breite,Staerke,Mindestmenge,c2.BockNr
order by Name
and I have following files here :
C:\Database\Augustdorf\Hegla-Lager
Glasdaten.db
Lagerdaten.db
Pappen.db
Any idea why is this working on Windows 2008r2 , but no longer on Windows 2012 ?
What am I missing here ?
Regards
Robert
As it turned out . BDE 5.11 was missing. This was in fact installed on Windows 2008r2 , but since the installer is really old it was not visible in Add Remove Programs, which led me to believe it was not installed.
Only after checking c:\Program Files(x86)\Borland\BDE folder ... did I realize that it was indeed installed.
Now only one minor problem exists . It seems like I need to Run the Application As Administrator to have enough rights ... but that is another question/answer.
thank you.

Invoke-SqlCmd vs .Net Framework based Sql Server Command

Just started getting my feet wet with interacting with SQL Server using PowerShell and have got this query:
For performing any sql server database operation, using .net framework based objects is my preferred choice mainly because of the reason that I come from C# background. For example:
$sqlCommand = New-Object System.Data.SqlClient.SqlCommand
However, I found that we can also use Invoke-SqlCmd cmdlet available in SqlServerCmdletSnapin100. As:
Add-PSSnapin SqlServerCmdletSnapin100
Set-Location SQLSERVER:\sql\DatabaseInstance\databases\TestDatabase
Invoke-SqlCmd -Query "SELECT * FROM [File]" -User "UserName" -Password "UserPassword"
Wondering, why one should ever go for using Invoke-SqlCmd instead of .net framework based objects?
Was Invoke-SqlCmd made available through PowerShell because some population out there is not familiar with .net framework.
Or
Are there any particular features offered by Invoke-SqlCmd for which we must use it.
Please guide.
Invoke-SqlCmd was made available through powershell by snapins, not by default. All it does is call the sqlcmd.exe, which existed before powershell, and was used to send sql commands through cmd. Now that we have direct access to .Net, we don't need it. There is nothing Invoke-sqlcmd can do that you can't do with .Net, SqlClient will always be the better choice IMO, because it is faster and you'll never get this "different behavior" Microsoft refers to.
http://technet.microsoft.com/en-us/library/ms162773.aspx
SQL Server Management Studio uses the Microsoft .NET Framework
SqlClient for execution in regular and SQLCMD mode in Query Editor.
When sqlcmd is run from the command line, sqlcmd uses the ODBC driver.
Because different default options may apply, you might see different
behavior when you execute the same query in SQL Server Management
Studio in SQLCMD Mode and in the sqlcmd utility.

Direct connect to FirebirdSQL with FireDAC on Android?

I need a direct connect to FirebirdSQL 2.x database (no DataSnap ).
Is it possible, and how ?
FireDAC DB connectivity depends on the existance of a DB client library for a specific platform. fbclient.dll / .so is required to connect to Firebird. There is no port of fbclient for Android. So, you cannot connect to Firebird from Android using FireDAC Firebird driver.
Actually, FDPhysFBDriverLink are not compiled for Android
maybe the easiest solution to retrieve or store data to and from FirebirdSql in this situation is creating small app that works as bridge between Android and FirebirdSQL. Using an unused port using Indy, it is very possible. How about format? You can use your own format, as long as it works, then everything is oke.
Security? Sorry, i did not think about security. After connection build, security is another menu.

advantage ole db provider 10.0.0.3 adsoledb for 64 bit - can't get it to work

trying to get a local server version of Advantage OLE DB Provider to work on a 64 bit Windows 7 machine. installed the 64 bit version 10.00.0.3 release and copied my application. registered the adsoledb64.dll from the app directory. I get nothing. Doesn't write a log either. Am I going to have to compile the app on the 64 bit machine? very confused and frustrated.
Based on the information I have gleaned from the comments, it sounds as if your application is running as a 32-bit application. If so, it will not be able to load 64-bit version of the OLE DB provider. The conn.Open(); call would likely result in an error such as this:
The 'Advantage.OLEDB.1' provider is not registered on the local machine.
One way to test this would be to install the 32-bit version of the provider to see if it works.
Alternatively, you might consider using the Advantage .NET Data Provider rather than the OLE DB provider. Using a native data provider instead of going through OLE DB might prove simpler in the long run.

Is it possible to write a script to easily deploy clr stored procedures?

I would like to include CLR stored procedure deployment in our deployment script (powershell at the moment), however I can't figure out a nice way to do this automatically.
I would have thought there would be a nice command line option to do the same as right-click deploy in Visual studio
Well, PowerShell itself won't give you much in the way of extra help. You don't mention which version of SQL, so I'll be a bit generic.
Really, all you need to do is have your script file copy the necessary DLLs for your CLR stored procs - PowerShell can copy files like a maniac, so no problem there. Then you need to execute the CREATE ASSEMBLY statement in SQL. PowerShell natively cannot help with this. If you're using SQL 2008, your script can Add-PSSnapin the SQL cmdlet provider, which will give you a cmdlet capable of executing SQL queries - so that gets you your CREATE statement.
If you don't have 2008, you'll have to write a short .NET routine to create a SqlConnection and SqlCommand - not difficult, and entirely possibly in PowerShell.
Next, use the same technique to execute your CREATE PROC statement to actually create the stored proc using the aforementioned assembly.
Zat help? Pity there's nothing more automated, true. MS hasn't spent a lot of brainpower simplifying complex SQL deployment stuff of this nature, I don't think, and CLR stuff adds a bit of extra spice since you have to make the assembly available.
One can use techniques described at http://msdn.microsoft.com/en-us/library/ms345099.aspx to generate deployment script from SSMS. At least this addresses the tedious part of generating a ton of CREATE PROCEDURE statements.
The SQL Server Publishing Wizard can script CLR stored procs as text. Looks like it converts the binary source of CLR stored procs as some kind of hex encoded text.

Resources