Monday, May 31, 2010

Use stored procedure to insert data ( VB.NET ) WEB APPLICATION

Use stored procedure to insert data ( VB.NET ) WEB APPLICATION

Simple Guide line for Insert data with VB.NET web forms
( Code for save data calling SP)

-->Import namespace="system.data" Import namespace="system.data.sqlclient"


Private Sub Page_Load(ByVal Source As Object, ByVal E As EventArgs)

Dim sql As String = "InsertEmployee"
Dim strConnection As String = "Data Source=local;Initial Catalog=TestDB;User ID=sa;Password='111';"
Dim conn As New SqlConnection(strConnection)

conn.Open()

Dim cmd As New SqlCommand(sql, conn)
cmd.CommandType = CommandType.StoredProcedure

cmd.Parameters.Add("@FirstName", "ASMA")
cmd.Parameters.Add("@LastName", "QURESHI")

Try
cmd.ExecuteNonQuery()
Catch ex As Exception
Response.Write("Error: " & ex.Message & "")
 
End Try
cmd.Connection.Close()
End Sub

Use stored procedure to insert data VB.NET ( Windows forms )

SAVE DATA ON SQL SERVER THROUGH CALLING SP ( VB.NET FORMS )


-->
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
 
Dim sqlSP As String = "stp_InsertUser"
Dim strConnection As String = "Data Source=.;Initial Catalog=DATAbaseName;User ID=sa;Password='111';"

Dim conn As New SqlConnection(strConnection)
conn.Open()

Dim cmd As New SqlCommand(sqlSP, conn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add(New SqlParameter("@UserLogin", SqlDbType.VarChar, 100, ParameterDirection.Input, _
False, 0, 0, "", DataRowVersion.Proposed, UsernameTextBox.Text))
cmd.Parameters.Add(New SqlParameter("@UserPwd", SqlDbType.VarChar, 100, ParameterDirection.Input, _
False, 0, 0, "", DataRowVersion.Proposed, PasswordTextBox.Text))
 
Try
cmd.ExecuteNonQuery()
MsgBox("User Added successfully ", MsgBoxStyle.OkOnly)
Catch ex As Exception
MsgBox("Please Enter UserName.", MsgBoxStyle.Critical)
End Try

cmd.Connection.Close()
 
End Sub

-------------------------------------------------------------------------------------
SQL SERVER Stored procedure ) SP

-->
Create PROCEDURE [dbo].[stp_InsertUser]
@UserLogin nvarchar(100),
@UserPwd nvarchar(100)
AS
--SET NOCOUNT ON
INSERT [dbo].[tblUser]
(
[UserLogin],
[UserPwd]
)
VALUES
(
@UserLogin,
@UserPwd
)

Thursday, May 27, 2010

VB.NET RadioButton Control. GRUP

The VB.NET RadioButton control allows you to choose one item within the parent control or group of items. When a user selects one option within a group of options the other options clear automatically. Typically the options are on the line of Yes/No, Male/Female, True/False etc. The RadioButton is very similiar to the CheckBox control. The main difference is with the CheckBox control, the user can select multiple choices within the same group of options.



Private Sub rbAll_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rbAll.CheckedChanged

UpdateRb()

End Sub


Private Sub rbPosted_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbPosted.CheckedChanged

UpdateRb()

End Sub


Private Sub rbNotPosted_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbNotPosted.CheckedChanged

UpdateRb()

End Sub



Public Sub UpdateRb()

If rbAll.Checked = True Then

rbNotPosted.Checked = False

rbPosted.Checked = False

ElseIf rbNotPosted.Checked = True Then

rbAll.Checked = False

rbPosted.Checked = False

ElseIf rbPosted.Checked = True Then

rbAll.Checked = False

rbNotPosted.Checked = False

End If





SQL server CAST and CONVERT int to Varchar

Transact-SQL Reference (SQL Server 2000)
CAST and CONVERT

SQL server CAST and CONVERT int to Varchar

USE pubs
GO

SELECT 'The price is ' + CAST(price AS varchar(12))
FROM titles
WHERE price > 10.00


GO

Price is integer filed - convert into varchar on select

Wednesday, May 26, 2010

Cristal report String Functions

Cristal report String Functions

The ability to modify and concatenate strings is a powerful feature of many programming languages, and Basic syntax doesn't disappoint. This section breaks out the different categories of string functions and summarizes how they work. The categories are: Analyzing a String, Parsing Strings, and Manipulating Strings.

Throughout this section, many of the functions listed use one or both of the arguments called compare and start. Rather than repetitively list their descriptions throughout the chapter, they are explained here for your reference.

The compare argument determines when string comparisons are supposed to be case sensitive. If compare is 0, the search is case-sensitive. If it is 1, the search is not case-sensitive. Case sensitivity means that even if two strings consist of the exact same letters, they will still be treated as different strings if one is upper-case and the other is lower-case. For example, �Joe� would not be the same as �joe�. The compare argument is optional. If it is left out, the comparison defaults to 0 (case sensitive).

The start argument tells the function to process characters starting at a specified position.[2] Any characters that are prior to that position are ignored. This argument is optional. If it is left out, then the function is performed for the entire string.

Converting Data Types

Basic syntax is a type safe language that requires all constants and variables in the same formula to be of the same data type. It also requires you to pass constants and variables as arguments using the exact data type that the formula expects. Even though the data types in Basic syntax are fairly simple, you still have to make sure that they are compatible. Fortunately, this shouldn't cause problems because there are functions to convert between the different data types. Table 6-5 lists these conversion functions.

Table 6-5. Conversion Functions

Conversion Function

Description

CBool(number), CBool(currency)

Convert to Boolean.

CCur(number), CCur(string)

Convert to Currency.

CDbl(currency), CDbl(string),

CDbl(boolean)

Convert to Number. Equivalent to ToNumber(). See the section �Formatting Values for Output�.

CStr()

Convert to String. Equivalent to ToText().

CDate(string), CDate(year, month, day), CDate(DateTime)

Convert to Date.

CTime(string), CTime(hour, min, sec), CDate(DateTime)

Convert to Time.

CDateTime(string),

CDateTime(date),

CDateTime(date, time),

CDateTime(year, month, day)

Convert to DateTime.

CDateTime(year, month, day, hour,

min, sec)

Convert to DateTime.

ToNumber(string), ToNumber(boolean)

Convert to a Number.

ToText()

Convert to String. Same as CStr().

IsDate(string), IsTIme(), IsDateTime()

Test a string for being a valid date/time.

IsNumber(string)

Test a string for being a valid number.

ToWords(number),

ToWords(number, decimals)

Convert a number to its word equivalent.

Most of the above functions are very simple. Pass the function a field/variable of one data type and it returns the equivalent in the other data type. The CBool() function takes a number or currency value and converts it to Boolean True or False. Any non-zero value is converted to True and zero is converted to False. When it is displayed on a report, it prints the words �True� or �False�.

The CCur() function takes a number or string and converts it to the Currency data type. When converting a string, it can have formatting characters in it (�$�, �,�, etc.) and it will still be converted properly.

The CDbl() and ToNumber() functions are equivalent. Pass each a value and it gets converted to a number.

The CDate(), CTime() and CDateTime() are all similar. Pass them a string and it gets converted to the proper data type. The string parser for this function is very sophisticated. It lets you pass strings as diverse as �Jan 19, 1991�, �5/26/1998� and �2002, Feb 04�. You can also pass numbers as individual arguments for representing the different parts of a date and time. See Table 6-5 for the various argument options.

When converting a string to a date or number, you run the risk of raising an error if the string isn't in the expected format. You can avoid this by testing the strings validity before converting it. The IsDate() and IsNumber() functions do this for you. They return True if the string can be properly converted. If not, they return False. For example, here is a function that converts a string to a date, but only if it is a valid date.

If IsDate({Invoice.ExpirationDate}) Then

��� Formula = CDate({Invoice.ExpirationDate})

End If

The ToWords() function takes a number and converts it to its equivalent in words. This is similar to writing a dollar amount on a check and then spelling out the full amount in words. It prints the decimal portion as �##/100�. You can set the number of decimals it displays by passing a number to the second argument, which is optional. Notice in the second example how it only displays one decimal place and it rounds it up to the next higher number.

'Demonstrate the ToWords() formula

Formula = ToWords(123.45)'Result is �one hundred twenty-three 45 / 100�

Formula = ToWords(123.45,1) 'Result is �one hundred twenty-three and 5 / 100

Math Functions

Table 6-8. Math Functions

Function Name

Description

Abs(number)

Return the absolute value.

Fix(number, decimals)

Return a number with a specified number of significant digits.

Int(number),numerator \ denominator

Return the integer portion of a fractional number.

Pi

3.14...

Remainder(numerator, denominator),

Return the remainder of dividing the numerator by the denominator.

numerator Mod denominator

Return the remainder of dividing the numerator by the denominator.

Round(number, decimals)

Round up a number with a specified number of significant digits.

Sgn(number)

Return a number's sign.

Sqr(number), Exp(number), Log(number)

The standard arithmetic functions.

Cos(number), Sin(number), Tan(number), Atn(number)

The standard scientific functions.

Most of these functions perform basic mathematical functionality. There are only a couple of interesting points to notice. Working with whole numbers and decimals is done numerous ways. The Fix() and Round() functions take a fractional number and truncate it to a specified number of digits. The Round() function will round up to the nearest decimal. The number of decimals to display is optional and the default is zero. The Int() function is similar to the Round() function except that it only returns the whole number and will round down to the nearest whole number. Table 6-9 shows how the three functions will return a different number depending upon the decimal portion and whether the number is positive or negative.


Table 6-9. Examples of Truncating Decimals

Function

1.9

-1.9

Fix()

1

-1

Round()

2

-2

Int()

1

-2

If you want to get the whole number and you have the numerator and denominator available. You can use the \ operator to perform integer division. This does the division and only returns the integer portion of the result. The Mod operator and Remainder() function return the remainder after doing the division.

'Demonstrate the integer division and the Mod operator

Formula = 10 \ 3'Returns 3

Formula = 10 mod 3'Returns 1

Formula = Remainder(10, 3)'Returns 1

Tuesday, May 11, 2010

HOW TO INSTALL CRISTAL REPORT WITH 64BIT for Visual Studio .NET 2008

1) INSTALL Crystal Reports 9 full with Key

2) INSTALL the
Package for 64 bit

Runtime Packages for Crystal Reports Basic for Visual Studio .NET 2008 This file contains the latest install packages required for deploying .NET applications using Crystal Reports Basic for Visual Studio .NET 2008 runtime.

Crystal Reports Basic for Visual Studio 2008 x86 Redistributable Package (32 bit)
Crystal Reports Basic for Visual Studio 2008 IA 64 Redistributable Package (64 bit)
Crystal Reports Basic for Visual Studio 2008 x64 Redistributable Package (64 bit)


Install the Runtime Packages for Crystal Reports with .Net 2008


Create EXE or Setup File in .NET Windows Application

Setup projects allow you to create installers in order to distribute an application. The resulting Windows Installer (.msi) file contains the application, any dependent files, information about the application such as registry entries, and instructions for installation. When the .msi file is distributed and run on another computer, you can be assured that everything necessary for installation is included; if for any reason the installation fails (for example, the target computer does not have the required operating system version), the installation will be rolled back and the computer returned to its pre-installation state.

The following steps will gives the elegant guidance to create an exe or installer file.

1, Go to file menu > click Add > new project >now “Add New Project” dialog will appear.

2.Select the “Other Project Types” and click “Setup and Deployment” projects,Choose “Setup Project”give name project name in name text box finally click OK.

3.New project appear in solution explorer,for eg., you have give the name “MyEXE” file will be displays with given name.

4.Right click the MyEXE > go View > click “File System”

5.You can see the “File System on TargetMachine”under three folders
Application Folder
User’s Desktop
User’s Program Menu

6.Select Application Folder and right click Add>Project Output>select Primary output

7. Select User’s Desktop richt click on the second window>click create new shortcut>select output file from Application folder>change the file name from primary output name to MyEXE

next >>


same procedure follows the user’s program menu also

8.If you want to change the Manufactures name for exe,just right click the project go to properties

change the properties as per you requirement

9.Finally Build the new project After successfully Build the project myEXE(Setup) will be appear in Application Debug or Release folder(depend upon the properties settings)

EXE or installer will be available on his physical path…

When you want to install the EXE on the client machine,you should be installed .NET Framework on that machine because, Applications and controls written for the .NET Framework v2.0 requires the .NET Framework Redistributable Package version 2.0 to be installed on the computer where the application or control runs.

Monday, May 10, 2010

IF YOU THINK

IF YOU THINK
If you think you are beaten, you are.
If you think you dare not, you don't!
If you like to win, but think you can't,
It's almost a cinch you won't.
you think you'll lose, you're lost;
For out in the world we find
Success begins with a fellow's will;
It's all in the state of mind.
If you think you are outclassed, you are,
You've got to think high to rise,
You've got to be sure of yourself before
You can ever win a prize.
Life's battles don't always go
To the stronger and faster man,
But sooner or later the man who wins
Is the man who thinks he can.

Do you consider these people failures?

Do you consider these people failures? They succeeded in spite of problems, not in the
absence of them. But to the outside world, it appears as though they just got lucky.
All success stories are stories of great failures. The only difference is that every time they
failed, they bounced back. This is called failing forward, rather than backward. You learn
and move forward. Learn from your failure and keep moving.

What is the moral of the story?

What is the moral of the story?
1. Many times we confuse intelligence with good judgment.
2. A person may have high intelligence but poor judgment.
3. Choose your advisers carefully and use your judgment.
4. A person can and will be successful with or without formal education if they have the 5
Cs:
¨ character
¨ commitment
¨ conviction
¨ courtesy
¨ courage
5. The tragedy is that there are many walking encyclopedias who are living failures.


ٍٍsome Quotes

EDUCATION DOES NOT MEAN GOOD JUDGEMENT


Successful people don't do great things, they only do small things in a great way.

Meri zaat zara e benishan




Tere siwa kya jaane koi,
dil ki halat Rabba saamne tere guzri mujh par

Kaisi qayamat Rabba

Main wo kis tarahn se karun bayan,
jo kiye giye hain sitam yahan

Main wo kis tarahn se karun bayan,
jo kiye giye hain sitam yahan

Sune kon meri yeh daastan,
koi hamnasheen hai na raazdan

Jo tha jhoot wo bana sach yahan,
nai kholi maine magar zuban

Yeh akela pan, yeh udaasiyan,
meri zindagi ki hai tarjman

Meri zaat zara e benishan

Meri zaat zara e benishan

Kabhee sooni subhun main ghoomna,
kabhee ujri shaam ko daikhna

Kabhee sooni subhun main ghoomna,
kabhee ujri shaam ko daikhna

Kabhee bheegi aankhun se jaagna,
kabhee beete lamhun ko sochna

Magar ek pal hai umeed ka,
hai mujhe Khuda ka jo aasra

Na hi maine koi gilla kiya,
na hi maine di hain duhaiyan

Meri zaat zara e benishan

Meri zaat zara e benishan

Main bataun kya mujhe kya mille,
mujhe sabr hi ka silla mile

Main bataun kya mujhe kya mile,
mujhe sabr hi ka silla mile

Kissi aaghi ki rida mille kissi dardgi ka silla mile

Kiss gham ki dil main jagah mille,
jo mera hai wo mujhe aa mille

Rahe shaad yuhin, mera jahan,
k yeh yaqeen main badle mera gumaan

Meri zaat zara e benishan

Wednesday, May 05, 2010

SQL Server - Altering / Adding Columns

You can add new columns to an existing table. .

ALTER TABLE [dbo].[phone]
ADD inactive_date DATETIME NULL

GO

Alter column

You can add modify an existing column

ALTER TABLE [dbo].[person]
ALTER COLUMN [lastname] VARCHAR(35) NULL

GO

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

ALTER TABLE mytable
ALTER COLUMN mycolumn datatype(new_width)

Saab kuch seekha hamne na seekhi hoshiyari

Saab kuch seekha hamne na seekhi hoshiyari




Duniya ne kitna samjhaya
Kaun hai apna kaun paraaya
Phir bhi dil ki chot chupa kar
Humne aapka dil behlaaya
Khud hi mar mitne ki ye zid hai humari
Khud hi mar mitne ki ye zid hai humari
Sach hai duniya waalon ke hum hain anaadi

Dil ka chaman ujadte dekha
Pyaar ka rang utarte dekha
Humne har jeene waale ko
Dhan daulat pe marte dekha
Dil pe marne waale marenge bhikhari
Dil pe marne waale marenge bhikhari
Sach hai duniya waalon ke hum hain anaadi

Asli nakli chehre dekhe
Dil pe sau sau pehre dekhe
Mere dukhte dil se poochho
Kya kya khwaab sunehare dekhe
Toota jis taare pe nazar thi hamari
Toota jis taare pe nazar thi hamari

Sab kuchh seekha humne na seekhi hoshiyari
Sach hai duniya waalon ke hum hain anaadi

Monday, May 03, 2010

SQL - find column name from table

Select column name from table

select column_name,* from information_schema.columns
where table_name =like '%YourTableName%'

Saturday, May 01, 2010

Select SQL IS NULL / NOT NULL

SQL IS NULL

How do we select only the records with NULL values in the "Address" column?

We will have to use the IS NULL operator:

SELECT LastName,FirstName,Address FROM Persons
WHERE Address IS NULL

The result-set will look like this:

LastName FirstName Address
Hansen Ola
Pettersen Kari

Note Tip: Always use IS NULL to look for NULL values.


SQL IS NOT NULL

How do we select only the records with no NULL values in the "Address" column?

We will have to use the IS NOT NULL operator:

SELECT LastName,FirstName,Address FROM Persons
WHERE Address IS NOT NULL

The result-set will look like this:

LastName FirstName Address
Svendson Tove Borgvn 23


SQL String Functions

SQL String Functions

Sql string function is a built-in string function.
It perform an operation on a string input value and return a string or numeric value.
Below is All built-in Sql string function :
ASCII, NCHAR, SOUNDEX, CHAR, PATINDEX, SPACE, CHARINDEX, REPLACE, STR, DIFFERENCE, QUOTENAME, STUFF, LEFT, REPLICATE, SUBSTRING, LEN, REVERSE, UNICODE, LOWER, RIGHT, UPPER, LTRIM, RTRIM


Example SQL String Function - ASCII
- Returns the ASCII code value of a keyboard button and the rest etc (@,R,9,*) .
Syntax - ASCII ( character)SELECT ASCII('a') -- Value = 97
SELECT ASCII('b') -- Value = 98
SELECT ASCII('c') -- Value = 99
SELECT ASCII('A') -- Value = 65
SELECT ASCII('B') -- Value = 66
SELECT ASCII('C') -- Value = 67
SELECT ASCII('1') -- Value = 49
SELECT ASCII('2') -- Value = 50
SELECT ASCII('3') -- Value = 51
SELECT ASCII('4') -- Value = 52
SELECT ASCII('5') -- Value = 53