sql server 2008 express数据库的连接字符串 [英] Connection string for sql server 2008 express database

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

问题描述

我在vb.net winform项目中以编程方式创建数据库。我想知道我使用的连接字符串是什么?我现在使用的那个是:





I am creating a database programmatically in a vb.net winform project. I am wondering what is the connection string I use? The one I used up to now has been:


connectionString = "Data Source=.\SQLExpress;Initial Catalog=Master;Integrated Security=True;MultipleActiveResultSets=True"







这是有效的,因为在我已经在SQL Server 2008 express中创建数据库之前,所以我只是连接到使用上述连接字符串的数据库。最初,当我创建项目时,它将连接到数据库并相应地使用数据库,但现在我想首先在程序中以编程方式创建数据库,然后让它执行它应该执行的操作。我应该更改连接字符串,如果是,我应该将其更改为什么?




This has worked because before I had the database already created in SQL Server 2008 express, so I was just connecting to the database that was there using the above connection string. Initially when I created the project, it would connect to the database and use the database accordingly, but now I want to create the database programmatically first in the project and then let it do what it's supposed to do. Should I be changing the connection string and if so, what should I change it to, to do this?

推荐答案

将初始目录从主更改为新数据库的名称。
Change the "Initial Catalog" from "Master" to the name for your new Database.


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

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