This is a common error that occurs when you are trying to display a record in ASP.NET from a DataSource such as a SQL database, and a field you requested within the code cannot be found within the result returned by the DataSource. For example if you use a SQL command to retrieve fields, and […]
How to retrieve a list of installed printers
Retrieving a list of available printers using .NET 2.0 is quite easy since it’s supported by the framework itself, and there’s no need to mess with unmanaged code. First add the using statement: Here’s the entire code in one page:
At compile I get error error CS0131: The left-hand side of an assignment must be a variable, property or indexer
You are trying to change the value of a constant or of a read-only property.
How do I prevent a console application from closing immediately?
You have two options.You run the application without debugging (instead of F5 pressCTRL+F5). Or, if you don’t want to run the application without the debugger, at the end of the application code add: Console.ReadLine() Then you end the program by pressing Enter.
How to get all logical drives on a system?
By calling a static method from System.Environment called GetLogicalDrives(). This returns a string array that you can easily iterate.Suppose you have a ListBox and a button: private void btnPopulate_Click(object sender, System.EventArgs e) { // Store in a string array string[] drives = Environment.GetLogicalDrives(); // Loop into the string array foreach(string strDrive in drives) { // Add […]
At compile I get error CS0138: A using namespace directive can only be applied to namespaces
You are trying to designate a class instead of a namespace for the using statement.For example: using System.Console; This is not correct because the using statement only works with namespaces, while Console is a class.
Can I use MySQL with C#?
Yes, you can use MySQL with C#.You can connect to the database by using ODBC driver and the System.Data.Odbc namespace. Search with Google for tutorials on how to connect to the database as there are some on the web.Here is one:http://www.devhood.com/tutorials
How do I stop the form from closing / How do I prompt the user to confirm the closing of the application when he presses the X button?
There are a few reasons why you may want this, in some applications, for example, you may want to ask the user if he wants to save the work before closing. You can easily do this by handling the form’s Closing event.In the following example we stop a form named Form1 from closing when clicking the ‘X’ shaped button: […]
Find Easter Sunday of any year
The Meeus/Jones/Butcher Gregorian algorithm is used for calculating the Easter Sunday of any given year using C#.
Crop a Picture using C#
A function to which you can pass the picture that you want to crap and the coordinates, and it will return a cropped vesion of the picture as a byte stream.