Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 SQL Server Database attaching types

Author  Topic 

kfsehgal
Starting Member

6 Posts

Posted - 2012-02-15 : 12:34:04
I am attaching DBs using following code.
Dim conn As New SqlConnection("Server=MyHomeServer\SQLExpress;Database=master;Integrated Security=SSPI")
Dim cmd As New SqlCommand("", conn)
cmd.CommandText = "CREATE DATABASE dbNoPWD ON ( FILENAME = 'd:\dbNoPWD.mdf' ), ( FILENAME = 'd:\dbNoPWD_log.ldf' ) FOR ATTACH"
conn.Open()
cmd.ExecuteNonQuery()
cmd.Dispose()
conn.Dispose()
Please note I donot want to give any username and password.


When I ran the above code and then checked SSMS, I found my attach DB was not checked in Roles
The problem with this is my network computers can not access this DB. I want to run some code like above (without sa password) and want that all my network computers can access the DB without my user get involved in setting up SSMS
I could not attach pic. Please visit
http://stackoverflow.com/questions/9295832/sql-server-database-attaching-types
to view my pic.
Thanks

X002548
Not Just a Number

15586 Posts

Posted - 2012-02-15 : 13:25:40
Can't you do all of this admin work using SQL Server Client tools?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page
   

- Advertisement -