基于服务的数据库和本地数据库之间的混乱 [英] confusion between service based database and local database

查看:206
本文介绍了基于服务的数据库和本地数据库之间的混乱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的c#,我是一个学生学习c#从最近3个月,当开始我的小项目,我创建了一个基于服务的数据库,并使用存储在表中的值。在我的应用程序,我只处理表。和查询将在单个机器上工作。我生成一个项目,只有在一个单一的机器上工作。所以我现在意识到基于服务的数据库和本地数据库之间的差异
**基于服务的数据库是一个只能通过服务器访问的数据库。它使用MDF数据文件,它是SQL Server格式。为了能够连接到SQL Server数据库,SQL Server服务必须正在运行,因为它正在处理您的请求并访问数据文件。

hi i am new to c# and i am a student learning c# from last 3 month and when starting my small project i created a service based database and use to store the values in the tables. in my app i am only dealing with the tables. and queries which will be working on a single machine. i am generating a project which only will be working on a single machine. so i now realised diffrence between service based database and local database **A service-based database is a database that is only accessed through a server. It uses an MDF data file, which is SQL Server format. To be able to connect to a SQL Server database the SQL Server service must be running, because it's that that processes your requests and access the data file.

本地数据库一个只对您的应用程序本地的。它使用SDF数据文件,这是SQL Server CE(精简版)格式。没有必要安装一个服务器来访问一个SDF数据库**
,但我形成了整个项目与基于服务的数据库,并使用所有查询是选择和更新。我使用这个代码

A local database is one that is local to your application only. It uses an SDF data file, which is SQL Server CE (Compact Edition) format. There is no need to install a server to access an SDF database** but i formed the whole project with the service based database and used all queries which is select and update. and i used this code

connectionString = @"Data Source=.\
    SQLEXPRESS;AttachDbFilename=E:\project\Database1.mdf;Integrated 
    Security=True;User Instance=True";
sqlConnection = new SqlConnection(connectionString);

但是当转换到.sdf文件意味着本地数据库,我只需要替换新的连接字符串?是否反映任何功能?

but when shifting to .sdf file means to local database i just have to replace the new connection string? does it reflects to any of the functioning?

推荐答案

如果数据库结构相同,保持不变。
唯一需要改变的是连接字符串

If the databases structures are the same, your code (potentially) has to be remain the same. The only thing has to be changed is the connection string.

还有其他类型的发行版可以在本地和服务器端存储之间产生差异:

There are other type of issures that can make difference between local and server side storage like:


  • 外部流程调用

  • 文件访问

  • 性能

等等。

但是从功能(通用)的观点来看,你的程序应该只改变连接字符串

But from functional (generic) point of view , your program should change only connection string.

这篇关于基于服务的数据库和本地数据库之间的混乱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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