Sunday 15 January 2012

c# - How to Export Data from SQL server Compact To Access MDB -


I need a solution to access all data from SQL Server CE to the MDB database.

I tried this approach (solution # 2) but the error is "no string or any database specified in these sections."

The code works if I connect to a non-compact SQL Server.

I think the problem is with the connection string in these sections, but I did not know how to change it.

This is my code:

  Private Zero ExportTable (string tableName, string source, string destination) {var connStr = string.format ("Provider = Microsoft.Jet. OLEDB.4.0; Data Source = {0} ", Destination); Var cmdText = string.Format ("Select {{source} from {0}} {data source = {1}; maximum database size = '4000'; continuous security information = wrong;];", tablename, source) ; (Var conn = new OleDbConnection (using connStr)) (conn.Open (); (Var cmd = new OleDbCommand (cmdText, {cmd.ExecuteNonQuery (Using conn))); // error on this line} conn. Close ();}}   

Connection String: Data Source = {1}; Maximum Database Size = '4000'; Continuous Security Info = False;

Update: The format of the Source DB should obviously be similar to the following in these sections:
[ Type ; Database = Path ]

( Eken :)

I

  var cmdText = string.Format ( "to select {0} [{0}] IN '' [SqlServer CE; DATABASE = {1}; ", tagname, source);   

I get a different error: the installable ISAM could not be found.

know for SQLServer CE? it is supported at all? I could not find any information about it.

I've also tried: SQL CE, Skyuelsiariarisii, Microsoft. SQLSERVER.CE.OLEDB.3.5, Microsoft. SQLSERVER.MOBILE.OLEDB.3.0 etc. - The same error ...

I think this barrier Here the barrier is that the era you are trying to use requires an ODBC connection from SQL Server and as far as I know that there is no ODBC driver for SQL Server Compact. I'm pretty sure the syntax is [ODBC; There is no OLEDB equivalent in access to driver = ...] , so the trick will not work with SQL Server Compact (as you've found, it does "real" SQL Works with the server because ODBC connections are supported for that platform.)

I was curious to see what I can achieve by using C # for SQL Server Compact Database An OLEDB connection (which is, as MRAACK has stated in his comment). I came with the following: This pulls the SQL table into the datatale, sets the status of each row in "Added", and then logs in the corresponding table.

  string myConnectionStringMDB = "provider = Microsoft.ACE.OLEDB.12.0;" + @ "Data Source = C: \ User \ Guord \ Desktop \ to CMDB;"; String myConnectionStringSQL = "provider = Microsoft.SQLSERVER.CE.OLEDB.3.5;" + @ "Data source = C: \ user \ public \ test \ myData.sdf;"; (OleDbConnection conSQL = New OleDbConnection (), conMDB = New OleDbConnection ()) using {conSQL.ConnectionString = myConnectionStringSQL; ConSQL.Open (); ConMDB.ConnectionString = myConnectionStringMDB; ConMDB.Open (); (Oledibi Command Simdiskyuel = New Oledibi Command (), Simdimdibi = Using new Oledibi Command ()) (Simdisyuelkcommen type = Sistmkdeta. Command type. Text; CmdSQL.Connection = conSQL; CmdSQL.CommandText = "SELECT * FROM [Table1] "; Var daSQL = new Sistmkdetakoldibi. Oledibeedataadaptr (Simdiskyuel); Var dt = new system. Data.DataTable (); daSQL.Fill (DT); system.Data in Foreach (dt.Rows. DataRow dr) {// change row status for "added" from "row unchanged". T throw them Dr. Sattiadd ();} CmdMDB.CommandType = System.Data.CommandType.Text; CmdMDB.Connection = conMDB; CmdMDB.CommandText = "SELECT * FROM [Table1]"; Var daMDB = new Sistmkdetakoldibi .OldiDataAdapter (CMDMDB); Var cbuilderMDB = New OleDbCommandBuilder (daMDB); CbuilderMDB.QuotePrefix = "[" CbuilderMDB.QuoteSuffix = "]"; daMDB.Update (DT);} ConSQL.Close (); conMDB.Close () ;}    

No comments:

Post a Comment