Search This Blog

Tuesday, September 22, 2009

Quick/Simple Ping in C#

private string PingServers(string host)
{
  try
  {
    System.Net.NetworkInformation.Ping ping = new System.Net.NetworkInformation.Ping();
    System.Net.NetworkInformation.PingReply pingReply = ping.Send(host);
    return "Status: " + pingReply.Status.ToString();
  }
  catch (System.Net.NetworkInformation.PingException e)
  {
    return e.Message;
  }
}

Monday, September 21, 2009

K2 SQL User Manager 101

K2 blackpearl now supports non-AD users to interact with their workflow tasks. This is performed via the integrated SQL User Manager (SQLUM) that is installed by default with K2 blackpearl. Previously, in K2.net 2003, K2 was configured to use either the default Activive Directory UM or the SQL UM. Blackpearl now installs and runs both by default.

Read More

How to implement a ASP.NET Security Provider for K2 blackpearl

The example below takes you through the steps to use the ASP.NET Authentication Provider with K2 blackpearl. A typical scenario where you might use the ASP.NET Security Provider is when your Web Application requires a user to login in order to view restricted content. This includes a K2 Worklist. This article shows how to take advantage of the out-of-box ASP.NET security components and how to extend it to enable successful integration with K2 blackpearl...

Read More


Wednesday, September 09, 2009

Tuesday, September 08, 2009

Checking the Job Status on Multiple Servers

Typically a DBA manages multiple SQL server instances. It is an important part of DBA’s job to make sure all the jobs are running as intended and scheduled on all servers. With many servers to manage this job is very tedious and time consuming if you have to manually check the jobs on each and every server. It is a management nightmare and every DBA’s Achilles-heel.

This article shows how to generate a comprehensive Job Status Report about all the jobs in a multi-server environment. You can use this report to check the status of all the jobs that are running on all servers with ease and make sure important production jobs run on schedule and have not slipped through cracks.

Step 1
First you have to create linked server connections on the master server for all your target servers that you want to monitor. For more information on how to create linked servers in SQL 2000, please check the topic “How to set up a linked server (Enterprise Manager)” in SQL Server Books Online or on the web. For help on setting up linked servers in SQL Server 2005 check the topic “Linking Servers” in books online. The following scripts will use the information from sysservers table which contains all the registered link servers in the master database. Please make sure that you can connect to all the linked servers before you proceed.

Step 2
This script creates a table called Job_Status on the master server. You have to substitute your database name for yourdb. This script is called 01_create_table_job_status.sql.

Step 3
Create the stored procedure called usp_mon_job_status_of_all_servers on the master server. You have to substitute your database name for yourdb The script is called 02_usp_mon_job_status_of_all_servers.sql.

Step 4
Create the stored procedure called usp_help_job_status on the master server. You have to substitute your database name for yourdb. The script is called 03_usp_help_job_status.sql

Step 5
Create a job that executes the procedure created in Step 3 on the master server. You can also create a schedule that runs this job daily on the master server. For more information on how to create jobs, job steps and schedules, please refer to the topic “Implementing Jobs” on SQL Server Books Online (BOL).

That’s it. You are all set. Now every day you just have to connect to the master server using Query Analyzer or SQL Server Management Studio, open a query window and run the proc usp_help_job_status as shown below. Replace your database name for yourdb.

Use yourdb
Go
Exec usp_help_job_status

And it will show you a report similar to the following:

- The Source of this article can be found @ sqlservercentral.com.

Thursday, September 03, 2009

SQL TCP/IP Connections Dropping

A while ago we were plagued at a client by connections that were being forcibly closed by SQL on our Live Production DB. At first I presumed this a network error at the client because in the event log on the server, the error, "Windows Domain Controller Could Not be Found" occurred often, so at first I thought that the network connection was then being dropped by the server losing connection to the network for some or other reason, this meant I escalated the issue to networks and the end result is we sat one night and redid the box, but the error came back and caused the same problems as before.

So after more investigation, I found that there were cases on the net where people had the same isses as us...

TCP/IP Connection was forcibly closed by the software in your machine
Operation cannot be completed because the Socket is not a Socket.
Software in your Remote Host has forcibly closed your connection.

The fix I applied which has led to 3 weeks of no further issues being logged is as follows...

• Open SQL Server Configuration Manager on your DB Server
• Expand the node SQL Native Client Configuration and click on Protocols
• Ensure that the Shared Memory option is disabled and that TCP/IP is ordered 1 and Named Pipes is 2

This fixed the problems we were having, again I only suggest this fix if you encounter the problems described above, obviously trying to understand what this fix does, which the guys on net coudn't explain was that Shared Memory was enabled and ordered 1, thus when the server ever took alot of strain, or had many connections, even though the connection limit was set to unlimited, it seems SQL would then go and close random/dormant/sleeping TCP Connections cause it gave priority to Shared Memory even though we never used Shared Memory.

Take note, though, becareful when disabling Shared Memory if you have applications that run on the SQL Box, so for example if we have web apps and the DB on the same server, this could end up breaking your application.

- sent by Robert aka Robbie aka Rabobi

Tuesday, September 01, 2009

Recursive Queries using Common Table Expressions (CTE) in SQL Server

If you had the need to create a table with index data quickly you can use this script:

WITH tmpData AS
(
SELECT 1 as iIndex
UNION ALL
SELECT iIndex + 1 FROM tmpData WHERE iIndex <=100 ) SELECT * FROM tmpData;

This works for Dates as well:

WITH tmpData AS
(
SELECT CONVERT('2009-01-01',DATETIME) As DateValue
UNION ALL
SELECT DATEADD(dd,1,DateValue) FROM tmpData WHERE DateValue < '2010-01-01' ) SELECT * FROM tmpData;

The Source of this article can be found here;

Convert byte array to hex string

If you are like me and you regularly need to use byte arrays or hex string, you know that it is very handy to convert a byte array to a hex string.
I was always confused as to why the framework would not have a native method to do this, so I used to write my own little method to do it that looked something like this.

StringBuilder sb = new StringBuilder();
foreach (byte b in myByteArray)
{
sb.Append(b.ToString("X2"));
}
string hexString = sb.ToString();

But low and behold, the framework does have a native method that does this, I was just looking in the wrong place.

So in the BitConverter class there is a ToString method that takes a byte array as a parameter and spits out a nice hex string for you.

string hex = BitConverter.ToString(myByteArray);

Jumpbox - Free Virtualization Platforms

Jumpbox is packaged VM's that you can download with pre-loaded open source software. Just download the jumpbox and there you have a virtual server up and running with CRM, Content Management or Discussion forums ect. Most popular:
  • Drupal 5.x Content Management System
  • SugarCRM 4.5.x CRM System
More here

Best of Open Source Software Awards 2009

Not all gold comes from Redmond.
Read more