如何连接我的数据库 [英] How To Connect My Database

查看:79
本文介绍了如何连接我的数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用sql server 2008 R2创建数据库.现在在其他计算机上安装此软件时必须安装sql server 2008 R2 Management Studio吗?不存在其他方式?(如何)

以及我如何设置在其他系统上运行的SqlConnection意味着动态连接到不同的用户. (我在Visual Studio中通过数据连接连接到数据库)

I Create my database with sql server 2008 R2 . now when setup this software in other computers must install sql server 2008 R2 management studio ? not exist other way ?(how)

and how i set SqlConnection that run at other systems mean connect to different users dynamically . (i connect to database with data connection in visual studio)

thanks.

推荐答案

首先,您必须使用名称空间,例如使用System.data.sqlclient

之后,您需要使用一个名为SqlConnection的类,然后您需要创建该类的对象并传递连接参数,例如:-



SqlConnection con =新的SqlConnection(数据源=服务器名称;初始目录=数据库名称;用户ID = ExpressSack;密码= ********");
Firstly u have to use namespace such as using System.data.sqlclient

After that u need to take a class that name is SqlConnection after that u need to make a object of this class and pass connection parameter such as:-



SqlConnection con = new SqlConnection("Data Source=servername;Initial Catalog=databasename;User ID=ExpressSack;Password=********");


查看这些链接可能会有一些想法
使用Installer类轻松部署SQL Server数据库 [ ^ ]

http://www.homeandlearn.co.uk/csharp/csharp_s12p3.html [ ^ ]

使用C#创建SQL Server数据库 [ ^ ]

http://social.msdn.microsoft.com/Forums/zh/csharpgeneral/thread/5808f536-f48d-4869-adf2-13b876984ae9 [
See these links You may get some idea
Deploy SQL Server databases easily with an Installer class[^]

http://www.homeandlearn.co.uk/csharp/csharp_s12p3.html[^]

Create a SQL Server Database Using C#[^]

http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/5808f536-f48d-4869-adf2-13b876984ae9[^]


这篇关于如何连接我的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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