c#-2.0

What is using connection in the code

折月煮酒 提交于 2019-12-12 20:21:36
问题 What is the purpose of using (connection) in the code - please explain me static void HasRows(SqlConnection connection) { using (connection)/// what is this line { SqlCommand command = new SqlCommand( "SELECT CategoryID, CategoryName FROM Categories;", connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { Console.WriteLine("{0}\t{1}", reader.GetInt32(0), reader.GetString(1)); } } else { Console.WriteLine("No rows found.")

changing theme of C# windows application

天涯浪子 提交于 2019-12-12 18:12:46
问题 in ASP we have so many ways to change theme . but is there any way for chanigngthe whole theme of a windows application/? 回答1: By default a winform app will inherit windows theme but you can explicitly change some ui properties like color,font etc. You can also consider moving to WPF for better and easy to implement UI. 回答2: Nope, at least not easily. But you could give WPF a try, you will need to upgrade to C# 3.0 for that. 回答3: Some 3rd party component sets support theming. Example :

Is it possible to reference a VS2005 website project from another project in the same solution?

拥有回忆 提交于 2019-12-12 16:58:19
问题 I'd like to add nunit testing to a VS2005 C# ASP.NET website project - so that I can excercise methods in the App_Code directory. It's recommended that the tests are added as a seperate assembly so that the testing code does not get delivered with the website - in this lies my question: When I add a new project into the solution which holds the website and try to add a reference to the website project it does not show up in the projects tab - is it possible to reference a website project from

What is the performance hit with downcasting?

我怕爱的太早我们不能终老 提交于 2019-12-12 12:40:06
问题 Just trying to get my head around Generics by reading this enlightening article by Juval Lowy Paraphrasing.. When you define a Generic class definition, it is compiled into IL. For value-types, as soon as you request for a specific value-type, it substitutes the T with your specific value type to obtain the IL for that specific configuration e.g. MyList<int> Benefit: No boxing and unboxing penalties. All good.. for reference types, the compiler replaces all instances of T in your definition

How to pass parameters to a method by reflection

与世无争的帅哥 提交于 2019-12-12 03:39:34
问题 Further to my precedent question, I want to pass parameters to the method "WriteTrace". But I don't know how to do this. Here the actual code : public class Trace { public void WriteTrace(object sender, EventArgs e) { Console.WriteLine("Trace !"); } } public void SubscribeEvent(Control control) { if (typeof(Control).IsAssignableFrom(control.GetType())) { Trace test = this; MethodInfo method = typeof(Trace).GetMethod("WriteTrace"); EventInfo eventInfo = control.GetType().GetEvent("Load"); //

HttpUtility.HtmlEncode to validate user entries

会有一股神秘感。 提交于 2019-12-12 02:43:45
问题 I am trying to validate user inputs (free text) on a web page before the data is stored in the database. The site's written using unconvensional asp.net, as it was largely upgraded from classic asp. I want to make sure / or protect users from entering text values along with invalid characters such html. At the moment, if the page is submitted it crashes. Should I use the HttpUtility.HtmlEncode to correct each text box entry? Does this sound feasible? Thanks in advance. 回答1: Yes One of the

Network Drive label

自古美人都是妖i 提交于 2019-12-12 02:34:59
问题 I'm trying to get the label of some network resources mapped as drives. When I use DriveInfo.GetDrives(), local volumes have the VolumeLabel filled parameter as expected, but in network drives it is an empty string. How can I get those labels? 回答1: You can use WMI for this - not sure of the exact query (it's been a while), but here's an example of how to get network drive free space: http://en.csharp-online.net/Network_Drive_Free_Space I think replacing 'name' with 'VolumeName' in that

Regarding Sorting MultiDimensional Arrays in C#

空扰寡人 提交于 2019-12-12 01:37:33
问题 I am trying to figure out a way to correctly sort a bunch of different arraylists. I am publishing content articles and every value [0] in an arraylist will relate to every other value [0]. and so on. Each element makes up the collective parts of a complete content item. Now, the last element, popularity, is the amount of clicks an item has received. How do I do a sort of the content items based on popularity without mixing up the html for each article? * EDIT I am limited by the .NET 2.0

Error Access denied for user MySQL server?

浪子不回头ぞ 提交于 2019-12-12 01:32:55
问题 Error ERROR [HY000] [MySQL][ODBC 5.1 Driver]Access denied for user (using password: YES) ERROR [HY000] [MySQL][ODBC 5.1 Driver]Access denied for user (using password: YES) 回答1: Make sure that your MySql server allows remote connections. If not you'll have to bind the database and user to the remote IP(s) You also need to check the servers firewall settings to make sure 3306 (or whatever you're using) is allowed and that incoming connections are permitted. 回答2: Must be the semicolon in the

Server Performance going down while we trying to get some data from Tridion 2009 broker LINK_INFO table using C# 2.0

浪子不回头ぞ 提交于 2019-12-12 00:43:12
问题 Actually I tried to implement Google Markup on our pages, so that our usercontrol will render below type of HTML on the page header section <link rel="alternate" hreflang="en-GB" href="http://www.mysite.com/english/index.aspx" /> <link rel="alternate" hreflang="de-DE" href="http://www.mysite.com/de/german/index.aspx" /> <link rel="alternate" hreflang="en-DE" href="http://www.mysite.com/de/english/index.aspx" /> <link rel="alternate" hreflang="ru-RU" href="http://www.mysite.com/ru/russian