Tag Archives: c#

Renaming Files using C#

This is an example of how to use C# to rename files. This example takes a passed path e.g. C:\Temp\ and a ‘new name’ and renames all files in the directory with the ‘new name’ plus an underscore and an … Continue reading

Posted in Programming | Tagged , , , | 2 Comments

Parametrised SQL Server Stored Proc From ASP.net / C# / OLEDB

Lets assume that we have a stored procedure that is defined in the following way, it doesn’t really matter what the actual body of the SQL is: We want to be able to call this procedure from an ASP.net page … Continue reading

Posted in Programming | Tagged , , , , , , , , , | Leave a comment

Adding Controls to Windows Form at Runtime C#

This is a basic introduction on how to add a control to a windows form using C#. In this example we will add a button to a form with an On Click event. Firstly let’s add the button with the … Continue reading

Posted in Programming | Tagged , , , , , , | Leave a comment

Populating Windows Forms ComboBox from SQL Server using OLEDB and DataTable

For the database connection, and populating the DataTable see my post: Populating ASP.net DropDownList from SQL Server using OLEDB and DataTable Hopefully you have now connected to your database and populated your DataTable. Now all we need to do is … Continue reading

Posted in Programming | Tagged , , , , , , , | Leave a comment

Populating ASP.net DropDownList from SQL Server using OLEDB and DataTable

Firstly we need to ensure that we have referenced System.Data.OleDb in order to connect to the Database. Now the database connection: NB: for connection string help / information this is a great resource http://www.connectionstrings.com/ Now we have our open database … Continue reading

Posted in Programming | Tagged , , , , , , , , | Leave a comment

Export DataGridView to CSV File with C#

Here is a bit of code that I use to export contents of DataGridViews to csv files. This is part of an application that pulls data from various spreadsheet forms so it can be imported into a database. Firstly we … Continue reading

Posted in Programming | Tagged , , , , , , | 11 Comments

Resizing Controls with Form Visual Studio C# VB.net

I can remember having to write the code to resize control in forms. These days Microsoft have made it much easier with the Anchor property. When you put a control on a form, e.g. a listbox, you’ll find that by … Continue reading

Posted in Programming | Tagged , , , , , | Leave a comment

Moving Items between two Listboxes in C#

This example shows how you can move items between two listboxes by double-clicking on the items. To start you need a form, with two listboxes (I labelled mine lstLeft and lstRight). I also added a button (btnList with the caption … Continue reading

Posted in Programming | Tagged , , , | Leave a comment

Reverse a string in C#

Lots of people seem to want to do this… one neat way is to utilise Array.Reverse Pass the string to a char array, use Array.Reverse then pass the char array back as a string.

Posted in Programming | Tagged , , , , | Leave a comment

Fibonacci Sequence into an Array in C#

The Fibonacci sequence, if you don’t already know, is built up by adding the two previous numbers to create the next in the sequence: I.e. 0, 1, 1, 2, 3, 5, 8, 13… etc As the sequence goes on indefinitely … Continue reading

Posted in Programming | Tagged , , , , | Leave a comment