Saturday, March 19, 2011

Display Log in Logviewer

1) Create the FileSystemWatcher and set its properties.



FileSystemWatcher_Log_1.Path = Directory.GetParent("C:\\temp").FullName;

FileSystemWatcher_Log_1.Filter = "MyLogFile.log";

NotifyFilters notifyFileters = new NotifyFilters();

notifyFileters = notifyFileters
NotifyFilters.LastWrite;

// You can choose other notification filters


FileSystemWatcher_Log_1.NotifyFilter = notifyFileters;

FileSystemWatcher_Log_1.EnableRaisingEvents = true;




2) Set the event handler.



this.FileSystemWatcher_Log_1.Changed += new

System.IO.FileSystemEventHandler(this.FileSystemWatcher_Changed);



3) Update GUI when event occours



// create stream writer only once so that whenever new log is appended in the log file,

// only that text will be shown in the list view (or which ever the gui component you are using).

if (null == sr_Log_1)

{

sr_Log_1 = new StreamReader(new FileStream(SelectedFileName_Log1_textbox.Text,

FileMode.Open, FileAccess.Read, FileShare.ReadWrite), true);

}

string line;

while (sr_Log_1.EndOfStream != true)

{

line = sr_Log_1.ReadLine();

if (line.Trim().Length == 0)

{

continue;

}

Log_1_listBox.Items.Add(line);

Log_1_listBox.TopIndex = Log_1_listBox.Items.Count - 26 + 1;



}






WIndows Communication Foundation


Now learn windows communication foundation in few easy steps.





Please find the power point presentation  and example of windows communication foundation

Monday, September 27, 2010

How to change from Windows Authentication to SQL Server Authentication (2005)

Durng installation of SQL Server 2005 i did not care for SQL Server Authentication and installed it Windows Authentication.
And later other users in the network could not use it for the guest account due to some problem.

Here are the steps if you need to add SQL Server Authentication also for SQL Server.


1) Run the following query to enable SQL Server Authentication using MS SQL Server Management Studio (after login as windows authentication)

"ALTER LOGIN sa ENABLE".

2) Set the password for the sa account
 "ALTER LOGIN sa WITH PASSWORD = 'sa1234"
Password should be strong enough else it will not be accepted and query will fail.

3) Stop the SQL Server service
 Right click on My Computer -> Manage , Computer Management window will open.
Select Service and Applications -> Services -> all the services which start from SQL and stop them.

4) Change in registry
click on Start  -> Run and Enter regedit press enter.
Registry Editor will be opened
Go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.1\MSSQLServer\LoginMode
and change the value to 2 (Hexadecimal), if its not 2.


5) Restart all services of SQL Server 2005 or restart your machine.
Posted by Sunil Dubey