Click here to Skip to main content
15,903,540 members
Home / Discussions / C#
   

C#

 
GeneralRe: CD OPEN Pin
Heath Stewart26-Feb-04 12:26
protectorHeath Stewart26-Feb-04 12:26 
GeneralRe: CD OPEN Pin
Nick Parker26-Feb-04 17:15
protectorNick Parker26-Feb-04 17:15 
GeneralRe: CD OPEN Pin
Judah Gabriel Himango26-Feb-04 8:47
sponsorJudah Gabriel Himango26-Feb-04 8:47 
GeneralRe: CD OPEN Pin
Matthew Hazlett26-Feb-04 9:49
Matthew Hazlett26-Feb-04 9:49 
GeneralRe: CD OPEN Pin
Anonymous26-Feb-04 9:09
Anonymous26-Feb-04 9:09 
GeneralTransact-SQL calls from within C# Pin
betterc26-Feb-04 7:59
betterc26-Feb-04 7:59 
GeneralRe: Transact-SQL calls from within C# Pin
Mazdak26-Feb-04 8:13
Mazdak26-Feb-04 8:13 
GeneralRe: Transact-SQL calls from within C# Pin
turbochimp26-Feb-04 8:39
turbochimp26-Feb-04 8:39 
Something like the following should do it:

static void DetachPubsDB()<br />
{<br />
	//Creates a connection<br />
	string connStr = "provider=SQLOLEDB;Data Source=(local);User ID=sa;Password=;Initial Catalog=master; Network Library=dbmssocn";<br />
	OleDbConnection conn = new OleDbConnection(connStr);			<br />
		<br />
	try<br />
	{<br />
		conn.Open();<br />
<br />
		//Detaches the database<br />
		OleDbCommand cmdDetach = new OleDbCommand("sp_detach_db", conn);<br />
		cmdDetach.CommandType = CommandType.StoredProcedure;<br />
		cmdDetach.Parameters.Add("dbname", "Pubs");<br />
		cmdDetach.ExecuteNonQuery();<br />
<br />
		//Attaches the database<br />
		OleDbCommand cmdAttach = new OleDbCommand("sp_attach_db", conn);<br />
		cmdAttach.CommandType = CommandType.StoredProcedure;<br />
		cmdAttach.Parameters.Add("dbname", "Pubs");<br />
		cmdAttach.Parameters.Add("filename1", @"C:\Program Files\Microsoft SQL Server\Data\MSSQL\Data\pubs.mdf");<br />
		cmdAttach.Parameters.Add("filename2", @"C:\Program Files\Microsoft SQL Server\Data\MSSQL\Data\pubs_Log.ldf");<br />
		cmdAttach.ExecuteNonQuery();<br />
	}<br />
	catch(Exception excp)<br />
	{<br />
		Console.WriteLine(excp.Message);<br />
	}<br />
	finally<br />
	{<br />
		if(conn.State == ConnectionState.Open)<br />
			conn.Close();<br />
		conn.Dispose();<br />
	}<br />
}


The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’

GeneralRe: Transact-SQL calls from within C# Pin
betterc26-Feb-04 9:37
betterc26-Feb-04 9:37 
GeneralRe: Transact-SQL calls from within C# Pin
turbochimp26-Feb-04 10:03
turbochimp26-Feb-04 10:03 
GeneralRe: Transact-SQL calls from within C# Pin
betterc26-Feb-04 10:14
betterc26-Feb-04 10:14 
GeneralPrinting and DpiX/DpiY Pin
duncanmeech26-Feb-04 7:48
duncanmeech26-Feb-04 7:48 
GeneralRe: Printing and DpiX/DpiY Pin
duncanmeech26-Feb-04 8:10
duncanmeech26-Feb-04 8:10 
GeneralDirectX Window Pin
SherKar26-Feb-04 6:23
SherKar26-Feb-04 6:23 
GeneralRe: DirectX Window Pin
Dave Kreskowiak26-Feb-04 8:37
mveDave Kreskowiak26-Feb-04 8:37 
GeneralRe: DirectX Window Pin
SherKar26-Feb-04 15:29
SherKar26-Feb-04 15:29 
GeneralRe: DirectX Window Pin
Dave Kreskowiak26-Feb-04 16:40
mveDave Kreskowiak26-Feb-04 16:40 
GeneralRe: DirectX Window Pin
SherKar27-Feb-04 3:15
SherKar27-Feb-04 3:15 
GeneralRe: DirectX Window Pin
Dave Kreskowiak27-Feb-04 4:02
mveDave Kreskowiak27-Feb-04 4:02 
GeneralRe: DirectX Window Pin
SherKar27-Feb-04 5:03
SherKar27-Feb-04 5:03 
GeneralRe: DirectX Window Pin
Dave Kreskowiak27-Feb-04 7:48
mveDave Kreskowiak27-Feb-04 7:48 
QuestionHow to count the running applications? Pin
yyf26-Feb-04 5:55
yyf26-Feb-04 5:55 
AnswerRe: How to count the running applications? Pin
SherKar26-Feb-04 6:19
SherKar26-Feb-04 6:19 
AnswerRe: How to count the running applications? Pin
Nick Parker26-Feb-04 6:56
protectorNick Parker26-Feb-04 6:56 
AnswerRe: How to count the running applications? Pin
turbochimp26-Feb-04 6:57
turbochimp26-Feb-04 6:57 

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.