Update SQL Server CE database (.sdf) from 3.5 to 4.0 - visual-studio-2012

I need to upgrade a SQL Server Compact database from 3.5 to 4.0 version. I am using linq-to-sql
I tried some things that I found on stackoverflow, that did not help:
I tried Add 4.0 connection dialog (no error messages, bak file was created)
I tried upgrading in code: (no error messages)
System.Data.SqlServerCe.SqlCeEngine engine= new System.Data.SqlServerCe.SqlCeEngine("Data source = ...");
engine.Upgrade();
I checked for database corruption (system returned that there are no corruption problems)
System.Data.SqlServerCe.SqlCeEngine engine= new System.Data.SqlServerCe.SqlCeEngine("Data source = ...");
engine.Verify();
After these operations I wanted to recreate dbml file - I received error message
Incompatible Database Version (..) DB version 4000000, Requested version 3505053 (..)
In debug mode I checked db.Connection.ServerVersion = returns 3.5.8080.0
In database connection properties version is 4.0.8876.1
Any suggestions?

Once you have upgraded your database to 4.0, you can no longer create a dbml file, as the Tool responsible for this only Works with 3.5 databasee files. One possible workaround is to have two version of the database, one 3.5 for dbml generation, and another for use. Remember to initialize the DataContext object with a SqlCeConnection object, otherwise 4.0 will not Work with LINQ to SQL - or you can try my SQL Server Compact Toolbox, that allows you to generate a DataContext directly from a 4.0 database file (must still initialize with SqlCeConnection object)

Related

.NET Core Keyword not supported: 'server'

The sample application on the following page does not start.
https://learn.microsoft.com/en-us/azure/app-service/tutorial-dotnetcore-sqldb-app?pivots=platform-linux
https://github.com/azure-samples/dotnetcore-sqldb-tutorial
As stated in the documentation
After downloading the sample application and creating the DataBase to connect to, an error will occur when the database migration is executed.
$ export ConnectionStrings__MyDbConnection="Server=tcp:db-host.database.windows.net,1433;Database=coreDB;User ID=<username>;Password=<password>;Encrypt=true;Connection Timeout=30;"
$ dotnet ef database update
Build started...
Build succeeded.
info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
Entity Framework Core 3.1.3 initialized 'MyDatabaseContext' using provider 'Microsoft.EntityFrameworkCore.Sqlite' with options: None
System.ArgumentException: Keyword not supported: 'server'.
at Microsoft.Data.Sqlite.SqliteConnectionStringBuilder.GetIndex(String keyword)
at Microsoft.Data.Sqlite.SqliteConnectionStringBuilder.set_Item(String keyword, Object value)
at System.Data.Common.DbConnectionStringBuilder.set_ConnectionString(String value)
at Microsoft.Data.Sqlite.SqliteConnectionStringBuilder..ctor(String connectionString)
at Microsoft.EntityFrameworkCore.Sqlite.Storage.Internal.SqliteDatabaseCreator.Exists()
at Microsoft.EntityFrameworkCore.Migrations.HistoryRepository.Exists()
at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String targetMigration, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_0.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Keyword not supported: 'server'.
Do you know the cause?
I'm using .NET Core 3.1.
If your intention is really use SQLite then you should check this patterns of connections string:
https://learn.microsoft.com/en-us/dotnet/standard/data/sqlite/connection-strings
If not, your code is accidentally calling the SQLite extension to configure your DbContext... Do a full search (Ctrl+Shift+F) in the entire solution for UseSqlite method and replace it for the desired database provider extension (probably will require a new package reference to your project)
The cause was that SQlite was specified where SQL server should be specified.
services.AddDbContext<MyDatabaseContext>(options =>
options. UseSqlite(Configuration.GetConnectionString("MyDbConnection")));
services.AddDbContext<MyDatabaseContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("MyDbConnection")));
Thank you for your cooperation.

Can not get document DB when using seesion

I'm trying to create a transaction with my document DB version 4.0.0.
I was able to open a session but when I try to get the database information I get this error messages:
session.getDatabase is not a function
let session = await beginTransaction('matan');
let assetSessionObject = session.getDatabase('matan').getCollection('test');
I'm using mongodb: 3.6.6 driver from, So maybe the problem is that there is no driver 4.0.0 yet?
Thanks
You're going to want to upgrade to a MongoDB driver that is compatible with 4.0. Even though sessions came out in MongoDB 3.6, if you want to use transactions with Amazon DocumentDB or MongoDB, you're going to have to upgrade to 4.0 compatible drivers anyways as that's major version when transactions was introduced.

Data source name not found and no default driver specified". Failed to acquire connection "DestinationConnectionOLEDB"

I have created a SSIS package to import the excel to sql. I have set the connection string and excel file path by expression.
After that I'm trying to invoke package by c# WPF application by
Microsoft.SqlServer.Dts.Runtime.DTSExecResult and passing value of connection string and excel path. My code is as shown below
Application app = new Application();
Package package = null;
//Load the SSIS Package which will be executed
package = app.LoadPackage("D:\\EMS-Docs\\new\\SSIS\\SSISProject\\obj\\Development\\Package2.dtsx", null);
//Pass the varibles into SSIS Package
//Microsoft.SqlServer.Dts.Runtime.Variables myVars = package.Variables;
package.Variables["User::EXLPath"].Value = "D:\\EMS-Docs\\SSIS\\PRACTICAL_1901_LOT-2.xls";
package.Variables["User::SQLConn"].Value = GlobalClass.TransactionalDBConnectionString;
//Execute the SSIS Package and store the Execution Result
Microsoft.SqlServer.Dts.Runtime.DTSExecResult results = package.Execute();
The error
SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005.
An OLE DB record is available. Source: "Microsoft OLE DB Provider for ODBC Drivers" Hresult: 0x80004005 Description: "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified".
Failed to acquire connection "DestinationConnectionOLEDB". Connection may not be configured correctly or you may not have the right permissions on this connection.
Error cause
The main error is:
"[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"
Which means that the main problem is in the connection manager or the connection string.
Possible solutions
Make sure that you have set the connection manager and Data Flow Tasks Delay Validation property to True
Make sure that you are passing a valid connection string value by executing the package from visual studio with the same variable value.
Make sure that the application mode (32bit/64bit) is identical with the ODBC driver version. As example: if you have 32-bit ODBC driver installed, make sure that you are running the application in 32-bit mode
If you are connecting to SQL Server you can use SQL Native Client or Microsoft OLEDB Provider for SQL Server instead of ODBC provider
Additional Information
Also, you can refer to the following knowledge base article for more information about the error possible causes / solutions:
DATADIRECT "DATA SOURCE NAME NOT FOUND AND NO DEFAULT DRIVER SPECIFIED" ERROR

Error 2007 - SQLyog

Good Morning,
I am trying to connect to a Mysql Data base using SqlYog, I have created a new connection and I have entered all the necessary informations (login,password & port). But when I click “ok”, I get this error message (Error 2007 : Protocol mismatch; server version = 1, client version = 10) . I have pinged the data base and it responds me successfully !!!
Could you please tell me how can I solve this problem, I need to access to the data base urgently.
Thanks a lot.
This is usually due to using a very old MySQL server (before 3.22.x) which has a different protocol version.
You can take a look at this link to see what all server versions are supported.
To check your server protocol version, go to the MySQL command line and type:
SHOW VARIABLES LIKE "%version%"
SQLyog supports only the protocol version 10.

Enterprise library 5.0 new database

I'm using the enterprise library 5.0 to establish a database connection.
after setting the config file I'm trying to create a new database instance through this line of code :
Database db = DatabaseFactory.CreateDatabase();
but I'm getting this error :
activation error occured while trying to get instance of type database key""
thanks in advance
You need to add the references to it and mark them to be copied locally (see here how to do it: http://msdn.microsoft.com/en-us/library/t1zz5y8c(v=vs.90).aspx)

Resources