Monday, January 28, 2008

The Chart free generation for Web Application from Google

Google Provided addition tool for Web developers  - The Google Chart API.

You can create a charts in very simple way - build necessary URL and will receive chart in one of 5 types (Line, Bar, Pie, Venn or Scatter).

A simple "pie" for example:

URL = "http://chart.apis.google.com/chart?
cht=p3&chco=4C8ED6&chs=250x120&
chl=Sun|Mon|Tue|Wed|Thu|Fri|Sat&chd=s:ABCDEFG"

and a result:

 

 

In your control next chart parameters: Data, Type, Colors, Labels, Style, Character mappings and several optional parameters.

To Home Page click HERE

Sunday, January 20, 2008

Find all tables, which includes column name

Get all table names for a specific column name

SELECT sysobj.name as Table_Name
FROM sysobjects sysobj
INNER JOIN syscolumns syscol
ON sysobj.id= syscol.id
WHERE syscol.name = 'COLUMN_NAME_FOR_SEARCH'



-------------------------------------------

Get all columns and table names for a 'like column_name' query

SELECT syscol.[name] as Column_Name,
sysobj.name as Table_Name
FROM sysobjects sysobj
INNER JOIN syscolumns syscol
ON sysobj.id=syscol.id
WHERE syscol.name like '%COLUMN_NAME%'
kick it on DotNetKicks.com
 

Thursday, January 17, 2008

Example & Tutorial of Rhino Mocks

In object-oriented programming, mock objects are simulated objects that mimic the behavior of real objects in controlled ways. A computer programmer typically creates a mock object to test the behavior of some other object, in much the same way that a car designer uses a crash test dummy to test the behavior of a car during an accident.

 Wikipedia 

To full guide in code examples about Rhino Mocks Click Here

Full guide how to configuring VS 2008 for debugging .NET Framework Source Code

Click here to read a article.

Thursday, January 10, 2008

SQL Server 2005, Clean your Database Records & reset Identity Columns, all in 6 lines

Well, I had a small issue regarding writing a script to clean a database we have and reset its identity columns in all tables. Although the database wasn't huge one (less than 100 tables) I had to trace relations to be able to delete child table's records before parent's ones because of the foreign key constraints. The solution is disable the foreign keys and delete records with no fear of any errors then enables the constraints again.
Well, I found a solution to disable all constraints without the need to go on each table and disable it manually. and I was happy to know that I can use this solution in deleting all records from all tables. Not only this I was able to use the same solution to reset identity columns in all tables.
The solution was to use this built in stored procedure sp_MSforeachtable. For help about this proc search for it in Books online or use this sp_helptext sp_MSForeachtable.
Now back to my 6 lines, bellow is how I re-zeroed my Database:

/*Disable Constraints & Triggers*/
exec sp_MSforeachtable
'ALTER TABLE ? NOCHECK CONSTRAINT ALL'
exec sp_MSforeachtable
'ALTER TABLE ? DISABLE TRIGGER ALL'

/*Perform delete operation on all table for cleanup*/
exec sp_MSforeachtable 'DELETE ?'

/*Enable Constraints & Triggers again*/
exec sp_MSforeachtable
'ALTER TABLE ? CHECK CONSTRAINT ALL'
exec sp_MSforeachtable
'ALTER TABLE ? ENABLE TRIGGER ALL'

/*Reset Identity on tables with identity column*/
exec sp_MSforeachtable
'IF OBJECTPROPERTY(OBJECT_ID(''?''),
'
'TableHasIdentity'') = 1
BEGIN DBCC CHECKIDENT ('
'?'',RESEED,0) END'




 


Via Moses on DotNetSlackers

Wednesday, January 09, 2008

How to check email works with no SMTP

<system.net>
<mailSettings>
<smtp deliveryMethod="SpecifiedPickupDirectory">
<specifiedPickupDirectory
pickupDirectoryLocation="c:\Test\" />
</smtp>
</mailSettings>
</system.net>


 
Via .Net Tip of The Day

Monday, January 07, 2008

How to extract URLs (href property) from HTML

protected ArrayList GetUrl(string text)
{
ArrayList listURL = new ArrayList();
Regex r =
new Regex("href\\s*=\\s*(?:(?:\\\
"
(?<url>[^\\\"]*)\\\")|
(?<url>[^\\s]* ))"
);
MatchCollection mathColl = r.Matches(text);

foreach (Match math in mathColl)
{
foreach (Group gr in math.Groups)
{
listURL.Add(gr.Value);
}
}
return listURL;
}