C#从SQL迁移到访问数据库 [英] C# migrate from SQL to access database

查看:86
本文介绍了C#从SQL迁移到访问数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我在c#中有一个winforms应用程序使用SQL数据库。

由于sql数据库需要sqlserver express安装在客户端机器上运行我决定改为访问。

我创建了数据库并相应地更改了连接字符串和数据源。

但我现在收到一个错误:

类型为'  System.TypeInitializationException' app中出现 





详细信息:

关键字不支持提供者



我不知道因为我使用sql如果我必须更改更多代码。

你知道可能出错吗?



提前致谢



我的尝试:



我的结论是:

  public   static  SqlConnection con =  new  SqlConnection( @ < span class =code-string> Provider = Microsoft.Jet.OLEDB.4.0; Data Source = | DataDirectory | \db.mdb;); 

解决方案

当您从SQL Server更改为Access时,您不必只需更改连接字符串:您还需要使用OleDbConnection而不是SqlConnection,OleDbCommand而不是SqlCommand,等等在那之后,

之后,一般来说,大多数事情都会在没有变化的情况下发挥作用,只要你避风港;使用过于异国情调的东西 - 它们在实际的SQL方面非常兼容以传​​递它们。

不要向后迁移。访问有比希拉里克林顿对FBI更多的问题。



所有你需要做的就是让SqlServer(在一个或另一个中)要求使用你的软件。您的安装人员可以为他们安装。



查看此链接,比较不同的sql server化身:



所有SQL Server Compact:SQL Server Compact,SQLite的比较, SQL Server Express和LocalDB [ ^ ]


Hi

I have a winforms app in c# witch uses an SQL database.
As the sql database needs sqlserver express installed in the client machine to run i decided to change to access.
I created the database and changed the connection strings and datasource accordingly.
But i get an error now:

An unhandled exception of type 'System.TypeInitializationException' occurred in app



details:
keyword not supported "provider"

I dont know as i used sql if i have to change any more code.
Do you know what could be wrong?

Thanks in advance

What I have tried:

my connstring is:

public static SqlConnection con = new SqlConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\db.mdb;");

解决方案

When you change from SQL Server to Access, you don't just have to change the connection string: you also need to use OleDbConnection instead of SqlConnection, OleDbCommand instead of SqlCommand, and so forth as well.
After that, generally speaking most things will work without changes provided you haven;t used anything too exotic - they are pretty compatible in terms of the actual SQL to pass them.


DO NOT migrate backwards. Access has more issues than the Hillary Clinton does with the FBI.

All you have to do is make SqlServer (in one for or another) a requirement of using your software. Your installer can install it for them.

Check this link that compares the different sql server incarnations:

Everything SQL Server Compact: Comparison of SQL Server Compact, SQLite, SQL Server Express and LocalDB[^]


这篇关于C#从SQL迁移到访问数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆