Click here to Skip to main content
15,919,749 members
Home / Discussions / C#
   

C#

 
GeneralRe: TraceListener.Close not called when added through config file... Pin
John Fisher26-Feb-04 11:09
John Fisher26-Feb-04 11:09 
GeneralQuestion on resizing a non-rectangular form Pin
Flack26-Feb-04 9:47
Flack26-Feb-04 9:47 
GeneralRe: Question on resizing a non-rectangular form Pin
John Fisher26-Feb-04 10:37
John Fisher26-Feb-04 10:37 
GeneralPanel Size to small Pin
Member 90966226-Feb-04 8:50
Member 90966226-Feb-04 8:50 
GeneralRe: Panel Size to small Pin
John Fisher26-Feb-04 10:41
John Fisher26-Feb-04 10:41 
QuestionMeasuring text - a bug in .NET? Pin
Judah Gabriel Himango26-Feb-04 8:42
sponsorJudah Gabriel Himango26-Feb-04 8:42 
AnswerRe: Measuring text - a bug in .NET? Pin
Dave Kreskowiak26-Feb-04 16:58
mveDave Kreskowiak26-Feb-04 16:58 
GeneralRe: Measuring text - a bug in .NET? Pin
Judah Gabriel Himango26-Feb-04 19:08
sponsorJudah Gabriel Himango26-Feb-04 19:08 
GeneralRe: Measuring text - a bug in .NET? Pin
Dave Kreskowiak27-Feb-04 3:54
mveDave Kreskowiak27-Feb-04 3:54 
GeneralCD OPEN Pin
Anonymous26-Feb-04 8:03
Anonymous26-Feb-04 8:03 
GeneralRe: CD OPEN Pin
Nick Parker26-Feb-04 8:35
protectorNick Parker26-Feb-04 8:35 
GeneralRe: CD OPEN Pin
Daniel Turini26-Feb-04 8:43
Daniel Turini26-Feb-04 8:43 
GeneralRe: CD OPEN Pin
Nick Parker26-Feb-04 8:52
protectorNick Parker26-Feb-04 8:52 
GeneralROTD Pin
Mazdak26-Feb-04 9:11
Mazdak26-Feb-04 9:11 
GeneralRe: ROTD Pin
Nick Parker26-Feb-04 9:16
protectorNick Parker26-Feb-04 9:16 
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 

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.