Posts

Showing posts from June, 2008

How to get the records while Inserting, updating and deleting in sql server 2005

There are three default inbuild tables, they are inserted, deleted. For both insert and update commands, the affected values are stored into inserted table and for delete command, the affected values are stroed into deleted . Example for insert. UPDATE Emp SET emp_present=1 output Inserted.* DELETE FROM emp output deleted.*

How to read the web.config file in console application

create a C# VS2005 Console application that read a web.config file to get a connection string and connect to a database, open the web.config using visual studio and save as in the bin directory with consoleapplication name. For example if console application name is myapp then config file name called myapp.exe.config, then using ConfigurationManager.ConnectionStrings can read the string values from the config. files.

How to get the latest file in the directory based up on the creation time using vc#.net

public static void GetlatestFilesList(String DirPath) { DirectoryInfo di = new DirectoryInfo(DirPath); if (di.Exists) { FileInfo[] rgFiles = di.GetFiles(SearchPattern, SearchOption.TopDirectoryOnly); //Sort the file based upon the creation time int i,j; for (i = 0; i rgFiles[j].CreationTime) { FileInfo fiTmp = rgFiles[i]; rgFiles[i] = rgFiles[j]; rgFiles[j] = fiTmp; } } } //Based upon the latest file we need to read the data foreach (FileInfo fi in rgFiles) { Console.WriteLine("FileName" + fi.Name + " Creation Time" + fi.CreationTime); } } else { Console.WriteLine("Could not find the Directory: {0}.", DirPath); } }