Click here to Skip to main content
15,887,350 members
Home / Discussions / C#
   

C#

 
GeneralRe: setting up the bootstrapping sample Pin
kornstyle5-May-04 11:00
kornstyle5-May-04 11:00 
GeneralPermissions for Registry Entry Pin
Nagendra Kamath K3-May-04 4:27
Nagendra Kamath K3-May-04 4:27 
GeneralRe: Permissions for Registry Entry Pin
Heath Stewart3-May-04 4:38
protectorHeath Stewart3-May-04 4:38 
QuestionMulltiLine DataGrid Header in C#? Pin
nrg3-May-04 4:10
nrg3-May-04 4:10 
Generalsetting time and date Pin
Amirjalaly3-May-04 3:47
Amirjalaly3-May-04 3:47 
GeneralRe: setting time and date Pin
Heath Stewart3-May-04 4:08
protectorHeath Stewart3-May-04 4:08 
GeneralC# sp_attach_db execute Pin
betterc3-May-04 3:28
betterc3-May-04 3:28 
GeneralRe: C# sp_attach_db execute Pin
Heath Stewart3-May-04 4:00
protectorHeath Stewart3-May-04 4:00 
Connect to the master database and simply execute the sp_attach_db stored proc on the database (using all three parameters, using paths local to the target machine - not yours!) like so:
SqlConnection conn = new SqlConnect(
  "Integrated Security=SSPI;Data Source=DBSRV1;Initial Catalog=master");
SqlCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sp_attach_db";
cmd.Parameters.Add("@dbname", SqlDbType.NVarChar, 128).Value = "MyDB";
cmd.Parameters.Add("@filename1", SqlDbType.NVarChar, 260).Value = 
  @"C:\Program Files\Microsoft SQL Server\MSSQL\Data\MyDB.mdf";
cmd.Parameters.Add("@filename2", SqlDbType.NVarChar, 260).VAlue = 
  @"C:\Program Files\Microsoft SQL Server\MSSQL\Data\MyDB.ldf";
try
{
  conn.Open();
  cmd.ExecuteNonQuery();
}
finally
{
  conn.Close();
}


 

Microsoft MVP, Visual C#
My Articles
GeneralRe: C# sp_attach_db execute Pin
betterc3-May-04 4:26
betterc3-May-04 4:26 
GeneralRe: C# sp_attach_db execute Pin
Michael P Butler3-May-04 4:34
Michael P Butler3-May-04 4:34 
GeneralRe: C# sp_attach_db execute Pin
betterc3-May-04 4:35
betterc3-May-04 4:35 
GeneralRe: C# sp_attach_db execute Pin
Heath Stewart3-May-04 4:36
protectorHeath Stewart3-May-04 4:36 
GeneralIPv6 help Pin
bouli3-May-04 2:10
bouli3-May-04 2:10 
GeneralRe: IPv6 help Pin
Jeff Varszegi3-May-04 2:29
professionalJeff Varszegi3-May-04 2:29 
GeneralRe: IPv6 help Pin
bouli3-May-04 2:43
bouli3-May-04 2:43 
GeneralRe: IPv6 help Pin
Heath Stewart3-May-04 2:45
protectorHeath Stewart3-May-04 2:45 
GeneralRe: IPv6 help Pin
bouli3-May-04 2:51
bouli3-May-04 2:51 
GeneralRe: IPv6 help Pin
Heath Stewart3-May-04 3:06
protectorHeath Stewart3-May-04 3:06 
GeneralRe: IPv6 help Pin
Heath Stewart3-May-04 2:44
protectorHeath Stewart3-May-04 2:44 
GeneralRe: IPv6 help Pin
bouli3-May-04 3:18
bouli3-May-04 3:18 
GeneralRe: IPv6 help Pin
Heath Stewart3-May-04 3:23
protectorHeath Stewart3-May-04 3:23 
QuestionPrograming USB in c++? Pin
lyto3-May-04 1:37
lyto3-May-04 1:37 
AnswerRe: Programing USB in c++? Pin
Corinna John3-May-04 1:50
Corinna John3-May-04 1:50 
QuestionBrowse files and folder control? Pin
Marlun2-May-04 23:19
Marlun2-May-04 23:19 
AnswerRe: Browse files and folder control? Pin
Mazdak3-May-04 1:51
Mazdak3-May-04 1:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.