Wednesday, September 30, 2009

Let see how to use Dictionary/SortedDictionary classes from System.Collections.Generic(C#)

Hi Readers,

Thank you again for your emails.I`ve been busy lately doing some code for my open source software i will be publishing next month.Again thank you for sending emails.I received 52 yesterday.

Today i will explain to you how to use these 2 classes Dictionary/SortedDictionary.

Dictonary

Step1:we have to import System.Collections.Generic:

using System.Collections.Generic;

Step2: we have to declare Dictionary object with new keyword


Dictionary dic = new Dictionary();


You have to remember that we are dealing with key/pair schema.

Step3:Now let`s add some items with Add(key,value) method


dic.Add(2000, "Talley");
dic.Add(10, "John");
dic.Add(200, "Sam");


Step4:Let`s use ContainsKey method to find values


if (dic.ContainsKey(2000))
{
string st = dic[10];
Console.WriteLine(st);
}
else
{
Console.WriteLine("No Match!");
}

You can also use ContainsValue method to query the Dictionay object.There are methods and
properties of Dictionay object you may have to take a look.
SortedDictionay and Dictonary classes have almost the same methods and properties except
SortedDictionay accepts ICompareras parameter like this:

SortedDictionary<string,int> sd=new SortedDictionary<string,int>(IComparer<string>();

SortedDictionary

In a SortedDictionary elements must be sorted when they are added, making insertion times slower.

Remember you could also link table columns to these Dictionay objects.

Thank you for stopping by.See you next time.
If you have any question concerning this post please feel free to send me email at
johnstalley@live.com

Talley
Software Developer,ISV
Raleigh,NC






Sunday, September 27, 2009

How to insert the result set of a store proc or dynamic batch into a new table using SELECT INTO?

Hi Readers,

Thank you for sending emails.I appreciate it.Now let do some coding.

Suppose you want to insert the result set of a store procedure or a dynamic batch into
a new table,but you do not know what the schema is that you need to create.
You can use SELECT INTO statement and OPENQUERY.Here is how it works:

1-SELECT INTO format

SELECT
INTO
FROM

ex:
SELECT CustomerID,CompanyName,Country
INTO US_Customers
FROM Northwind.dbo.Customers

NB Do not create US_Customers in Nort
hwind database before executing the query.This table
US_Customers is created automatically for you after query execution.

2-The main query of concern(see title)

EXEC sp_serveroption,'data access',true;
SELECT *INTO FROM OPENQUERY(,'EXEC {(

That`s all i want to share with you today.
See you!

Talley Ouro
.Net Developer(Web&Smart Client Development)
Email: johnstalley@live.com



Thursday, September 10, 2009

Adding NUnit Tool to any version of Visual Studio

Hi Readers,

Thank you for sending me emails.I appreciated it.
Here is easy way to integrate Unit framework to Visual Studio.

1-First download NUnit at http://www.nunit.org/index.php?p=home

2-Copy nunit.framework.dll to the bin section of your project.

3-Add this reference to you project by right clicking on the project and click add reference



Now the dll is referenced to your project you can start using NUnit framework.

4-Go to Tools/External Tools(this task add NUnit tool to your visual studio-design time)











Thank you for visiting my blog.

Talley Ouro
Application Developer
Raleigh,NC

Monday, September 7, 2009

How to load a document with JavaScript?

Hi Readers,

Thank you for sending me emails.I appreciate it.
Happy holiday to you and your families.

Here is a single function you can use to load a page:

function ViewDocument(strDocument)
{
strDocument = escape(strDocument);
if (strDocument != null) //or strDocument!=undefined
{
//window.open(strDocument,"resizable:yes;scroll:yes;status:no;");
window.open(strDocument);
}
else
{
alert("Document Unavailable");
}
}

Thank you for visiting my blog.

Talley
Web & Windows Developer
Raleigh,NC

Tuesday, September 1, 2009

How to animate images with JavaScript?

Hi Readers,

Here are steps required to animate images using javascript:


Step1:Download AnimateByTalley.js from downlad page of my blog

Step2: create a new web form,add 2 htlm buttons and one image.
Everything should look like this:

Step3: reference AnimateByTalley.js in the head section of your page or
you can just copy the scripts and add it your page




That`s all you need to animate image with JS.

Thank you for visiting.
If you have any question or concern please feel free to email me
at johnstalley@live.com

Talley Ouro
Web & Windows Application Developer
Raleigh,NC

About Me

My photo
Raleigh, NC, United States
I am a software developer based in Raleigh,NC,USA.I design softwares and systems ;i also do consulting for companies worldwide.I program with these languages:VB.NET 2003/2005/2008;C#;Java(fun),SQL(200,2005,2008);ASP.NET 2.0/3.5;ASP.NET AJAX;ASP.NET MVC;JavaScript;JQuery;Windows Workflow Foundation;Web Services.I have 4 years + in programming.