Sunday, September 21, 2008

SQL TRANSACTION

The below code perform sql transaction in VB.NET. We can use this code in C# also by making only some changes.


Try
con.Open()
trans = con.BeginTransaction
com.Transaction = trans
com.Connection = con

strSql = "Insert into Departments values('005','ABC')"
db.Save(strSql, com)

strSql = "Update Departments set department_name='EF' where department_code='002"
db.Save(strSql, com)
trans.Commit()
Catch ex As Exception
MsgBox(ex.Message)
trans.Rollback()
Finally
con.Close()
End Try

STRING CASES

To Capitalize all the characters in a string we use:

ucase( string_name )

To make all the characters of a string Small Letters we use:

lcase( string_name )

To Capitalize first letter of string we use:

StrConv( string_name , VbStrConv.ProperCase)

MessageBoxButtons.YesNo

To interact with user before saving any record or performing a very important operation we can re ask him through dialog result by following the below method.

Dim Buttons As Integer = MessageBoxButtons.YesNo

Dim Result As DialogResult

Result = MessageBox.Show(Me, Message, Caption, MessageBoxButtons.YesNo, _
MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)


If Result = DialogResult.Yes Then
MessageBox.Show("You choosed Yes")
else
MessageBox.Show("You choosed No")
End If

Invalid KeyCodeV2.dll or KeyCodeV2.dll Not Found

The reason you are getting this error is because the machine that you are trying to run your application on does not contain the drivers Crystal Report needs to run. Here is your solution:

Finding Out What the Crystal Report Distribution Key is on VS.NET 2003:

1- Open VS.NET 2003
2- Click on Help Menu Option
3- Choose "About Microsoft Development Environment"
4- Look under Crystal Reports for Visual Studio .NET, you will see a 19 character number, which is the Distribution Key Code:

Example: AAA00-BB00000-C0000DD

Producing the Deployment Project:

Open Solution Explorer, right click on the “Solution Name” at the top and Add a New Project. On the window that appears, move to Setup and Deployment Projects. Click on Setup Project (not the wizard), put a name for your deployment project (make a note of the location where the folder that the deployment project will be created in) and then click OK. A File System dialog will appear – solution explorer should be displayed on the left of screen. Within solution explorer – right click over your deployment project and select Add – Project Output. Another window will appear – select Primary Output (make sure configuration is showing Active) and click OK. This will result in the detected dependencies being updated & a primary output icon appearing in the deployment project. Right click on the deployment project name again and Add – Merge Modules. Add the following modules.

Crystal_Database_Access2003.msm
Crystal_Database_Access2003_enu.msm
Crystal_Managed2003.msm
Crystal_regwiz2003.msm
VC_User_CRT71_RTL_X86_---.msm
VC_User_STL71_RTL_X86_---.msm

These were the appropriate modules for my application given that I am using VS 2003. Yours may be slightly different.

Right click on Crystal_regwiz2003.msm and go to its properties. Enlarge the MergeModuleProperties tree and enter the product licence key which is like this AAA00-BB00000-C0000DD that we found above.

Go onto Build – Configuration Manager . Check that the Project & Deployment Project which appear are set to “Release” and the Build check box for each is checked. Build the Project. If all is well the build should show no errors.

If this has gone according to plan you should now have (in the folder specified in the “location” window given when you added your deployment project) a debug and release folder. The release folder will contain:

- setup (application)
- setup (config file)
- an installer package

The release folder is all that is needed to deploy the application on another machine.

Wednesday, September 17, 2008

How to Use VLOOKUP or HLOOKUP to find an exact match

SUMMARY

The VLOOKUP and HLOOKUP functions contain an argument called range_lookup that allows you to find an exact match to your lookup value without sorting the lookup table.

Note It is not necessary to sort the lookup table if you use the range_lookup argument correctly.


MORE INFORMATION

The syntax of these functions are defined as follows.


VLOOKUP Function

=VLOOKUP(lookup_value,table_array,col_index_num,range_lookup)


where:

Argument Definition of argument
---------------------------------------------------------------------

lookup_value The value to be found in the first column of the array.

table_array The table of information in which data is looked up.

col_index The column number in the table_array for which the
matching value should be returned.

range_lookup It is a logical value that specifies whether
you want to find an exact match or an approximate match.
If TRUE or omitted, an approximate match is returned; in
other words, if an exact match is not found, the next
largest value that is less than the lookup_value is
returned. If FALSE, VLOOKUP finds an exact match. If an
exact match is not found, the #N/A error value is returned.


Note If range_lookup is TRUE or omitted (for an approximate match), the values in the first column of table_array must be sorted in ascending order. If range_lookup is FALSE (for an exact match), the table_array does not need to be sorted.
Example That Uses FALSE as the Range_lookup Argument
The following list contains some fruits and their respective colors. Notice that the first column is not sorted:



A1: Fruit

B1: Color

A2: Kiwi

B2: Green

A3: Grape

B3: Yellow

A4: Banana

B4: Red

A5: Apple

B5: Pink



The following formula finds the color (Red) that corresponds to the fruit Apple. You can type the formula in any cell on the worksheet:

=VLOOKUP("Apple",A2:B5,2,FALSE)


Notice that if you change the range_lookup argument to TRUE, Excel returns the #N/A error, because the first column is not sorted.


HLOOKUP Function

=HLOOKUP(lookup_value,table_array,row_index_num,range_lookup)


where:

Argument Definition of argument
---------------------------------------------------------------------

lookup_value The value to be found in the first column of the array.

table_array The table of information in which data is looked up.

row_index The row number in the table_array for which the
matching value should be returned.

range_lookup It is a logical value that specifies whether
you want to find an exact match or an approximate match.
If TRUE or omitted, an approximate match is returned; in
other words, if an exact match is not found, the next
largest value that is less than the lookup_value is
returned. If FALSE, VLOOKUP finds an exact match.
If an exact match is not found, the #N/A error value is
returned.


Note If range_lookup is TRUE or omitted (for an approximate match), the values in the first row of table_array must be sorted in ascending order. If range_lookup is FALSE (for an exact match), the table_array does not need to be sorted.
Example That Uses FALSE as the Range_lookup Argument
The following list contains some fruits and their respective colors. Notice that the first column is not sorted:

A1: Fruit

B1: Color

A2: Kiwi

B2: Green

A3: Grape

B3: Yellow

A4: Banana

B4: Red

A5: Apple

B5: Pink



The following formula finds the Color column, and returns the third item (-1) for the heading Yellow. You can type the formula in any cell on the worksheet:

=HLOOKUP("Color",A1:B5,3,FALSE)


Notice that if you change the range_lookup argument to TRUE, Excel returns the #N/A error, because the first column is not sorted.

Friday, September 5, 2008

Where the Favourites Websites of Internet Explorer Stored??

The favourites websites are stored on the following location.

C:\Documents and Settings\YOUR_LOGIN_NAME_FOLDER\Favorites

Where the BookMarks of Firefox Stored in HardDisk??

A file with extension ".json" stored on your harddisk on the following location.

C:\Documents and Settings\Administrator.QUALITY\Application Data\Mozilla\Firefox\Profiles\e111rkk7.default\bookmarkbackups


Just Open it and you will get your favourite sites.