-
Recent Posts
Categories
Meta
Tag Archives: c sharp
Shuffle an Array in C#
As part of a basic guessing game I wanted to be able to shuffle an array of n chars into a random order. The method I decided to use was the following. Create a loop to iterate n times (where … Continue reading
Loading Data into a DataReader and Looping Through Records OLEDB / C#
Just a quick example of loading data into a data reader using C#. My data source is MS SQL Server in this case, although you would just need the correct OLEDB connection string to use any other data source. Couple … Continue reading
Image Slideshow on Windows Form C# with Timer Control
Quick example of how to display an image control that loops through a folder of images. Firstly drop a timer control onto your form (name: tmrNextImage), set the Interval to 1000 milliseconds (1 second) and set enabled to true. Next … Continue reading
Find all Subdirectories from a given path using C# – With Error Handler
In my earlier post () I showed how you can iterate through folders and add the folder names to a list (lstDirs). The problem with this code was that if you encountered a folder you didn’t have access to it … Continue reading
Null Dates in SQL Stored Procedure called from C# – Conversion Error DateTime2 DateTime
One issue with calling stored procedures from C# is with null date parameters. If you try to pass an unassigned DateTime type to the parameter you will receive an error regarding conversion of DateTime2 to DateTime data type. One way … Continue reading
Posted in Programming
Tagged c sharp, c#, datetime, null, parameters, programming, stored procedure
1 Comment
Assign Event to Multiple Controls, Windows forms and C#
Lets say that you want the same event to be triggered by multiple controls. You don’t want to have to rewrite the code for all the controls. Here we’re going to use four buttons with one shared event that shows … Continue reading
Posted in Programming
Tagged c sharp, c#, controls, events, programming, windows forms
Leave a comment
Find all Subdirectories from a given path using C#
To load the subdirectories for a given file path. We simply need to use the GetDirectories method of DirectoryInfo (this example loads the results into a listbox lstDirs) E.g. N.B. sPath needs to be a full path including drive letter … Continue reading
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
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 asp.net, c sharp, c#, oledb, parameters, programming, sql, sql server, stored procedure, tsql
Leave a comment