首次创建数据库 [英] create database first time
问题描述
嗨。
问题:
无法找到关于这个问题的任何信息。也许是因为它如此简单?
我想创建我的数据库并使用它。我使用SQLEXPRESS服务器2005.
问题:
我第一次创建数据库我需要连接到服务器才能创建my.mdf和my.ldf才能使用他们。
我的字符串看起来像这样,工作正常。
Server = .\SqlExpress; Database = master; Integrated Security = SSPI
下次我想连接到my.mdf我无法连接到工作。那个字符串应该是什么样的?
我试过这个并且它不起作用。
Server = .\SqlExpress; AttachDBFilename = my.mdf; User Instance =真的;综合安全性=真;
任何人都知道这件事,已经试过了吗?
Hi.
Problem:
Cant rely find any info on this question. Maybe because it so easy?
I want to create my database and use it. I use SQLEXPRESS server 2005.
Question:
First time I do CREATE DATABASE I need a connection to the server to create my.mdf and my.ldf before I can use them.
My string looks like this and works fine.
"Server = .\SqlExpress; Database = master; Integrated Security = SSPI"
Next time I want to connect to my.mdf I cant get a connection to work. Howe should the string look like?
I have tried this and it dos not work.
"Server =.\SqlExpress; AttachDBFilename = my.mdf; User Instance = True; Integrated Security = True;"
Anyone that knows anything about this, that has tried it him self?
推荐答案
在这里查看许多类型的连接字符串的示例。
http://connectionstrings.com/sql-server-2005 [ ^ ]
但通常在您执行CREATE DATABASE调用后,您只需更改数据库= master到您创建的数据库的名称。没有扩展名,因为已在该服务器上创建了数据库。如果您想告诉不同的服务器附加到您的外部文件,那么AddDBFilename将起作用。看看网站。这是对这些事情的一个很好的参考。
Look over here for an example of many types of connection strings.
http://connectionstrings.com/sql-server-2005[^]
But typically when after you do your CREATE DATABASE call then you can just change the Database=master to the name of the database you created. Not with the extension, because the database has already been created on that server. If you wanted to tell a different server to attach to your external files, then the AddDBFilename would work. Take a look at the website. It is a great reference for these things.
这篇关于首次创建数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!