Wednesday, November 25, 2009

Stored Procedure Using Select Statement

ALTER PROCEDURE [dbo].[getOrderDetails] (@username VARCHAR(50))

AS
BEGIN


SELECT * FROM orders WHERE username = @username;

END

Stored Procidure For Login

ALTER procedure [dbo].[getlogindata] as
select username,password from customers

updating recorde Using StoredProcidures

ALTER proc [dbo].[updatestore]
(
@username varchar(50),
@address varchar(50),
@city varchar(50),
@postalcode varchar(50),
@phone varchar(50),
@emailid varchar(50)
)
as
begin
update stores set

address=@address,
city=@city,
postalcode=@postalcode,
phone=@phone,
emailid=@emailid
where username=@username
end

stored procidure fpr Searching

ALTER proc [dbo].[usp_searchpro]
(
@city varchar(50),
@state varchar(50),
@MaxPrice money,
@minprice money,
@bedrooms int,
@bathrooms int
)
as begin
declare @k money;
select @k= price from Propertyreg where price>@minprice and price<@maxprice

select * from propertyreg where city=@city OR state=@state aND
price=@k and numbedrooms=@bedrooms OR numbathrooms=@bathrooms

end

get Maxid Using Storedprocidure

ALTER PROCEDURE [dbo].[usp_insertProductDetails](
@Product_Name varchar(50),
@Cost varchar(50),
@Description varchar(50),
@UserName varchar(50)

)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @ID INT;
SELECT @ID = 1+ ISNULL(MAX(ProductID),0) FROM dbo.Product_Details
INSERT INTO dbo.Product_Details(
ProductID,
Product_Name,
Cost,
Description,
UserName,

Approved)
VALUES(
@ID,
@Product_Name,
@Cost,
@Description,
@UserName,
0

)
END

inesrting records Using Stored Procidures

ALTER procedure [dbo].[insertbilling]
(
@ccnumber varchar(50),
@ccexp varchar(50),
@cardholdername varchar(50),
@address varchar(50),
@city varchar(50),
@state varchar(50),
@zip varchar(50),
@username varchar(50)
)
as begin insert into billing values
(
@ccnumber,
@ccexp,
@cardholdername,
@address,
@city,
@state,
@zip,
@username
)
end

Visual Studio 2008 Keyboard Shortcuts

Visual Studio 2008 Keyboard Shortcuts

Here are some extremely helpful keyboard shortcut keys for Visual Studio 2008. You probably know most, but some you won't know. For instance, did you know that Ctrl+. is the same as Sift+Alt+F10?

Note: Some of the shortcuts won't work in all environment configurations (web, C#, etc).

To use, hold down the control key and hit the key combination. Works on the whole document, a specific line, or a selection of code.

Update References/ Add Using Statement (Ctrl +. or Shift +Alt +F10)
I'm referring to the underline that appears under a variable to perform an action like add a using statement, or refacter a method or class name. Not sure what it's called but I use it all the time. Ex: ClassName

List Members (Ctrl +J or Ctrl +K, L)
Displays the autocomplete list for classes, methods, or properties.

List Parameter Info (Ctrl +Shift +Space or Ctrl +K +P)
Lists the parameters for a method. Use this shortcut when your cursor is inside the parenthesis of a method.

Auto Format (Ctrl +K, D or Ctrl +E, D)
Formats C#, VB, ASPX, Javascript, CSS, XML, XSL, and HTML code according to generally accepted formatting standards for the respective programming language. Makes code look nice and neat.

Quick Watch (Ctrl +Alt +Q)
Highlight some code and hit these shortcut keys to display the Quick Watch dialog.

Comment / Uncomment (Ctrl +K, C / Ctrl +K, U)
Comments or uncomments a block of code. Works with C#, VB, ASPX.

Code Bookmarks
Use these to bookmark a line of code. You can cycle through the bookmarks across any file within a project. Bookmarks come in very handy, try it out.

Set/Unset Bookmark (Ctrl +K, K)
Next Bookmark (Ctrl +K, N)

Surround With (Ctrl +S)
Surrounds a block of code with a code snippet.

Build & Debug Shortcuts
Set/Unset Breakpoint (F9)
Build (F6 or Ctrl +Shift +B)
Start Debugging (F5)
Start Without Debugging (Ctrl +F5)
Stop Debugging (Shift +F5)
Continue (F5)
Step Over (F10)
Step Into (F11)
Step Out (Shift +F11)

Generics Concept using LINQ s

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace generics
{
class Program
{
static void Main(string[] args)
{
List mygoObj = new List{
new mygoclass { EmpId = 1, Ename = "raju" },
new mygoclass { EmpId = 2, Ename = "Srinu" },
new mygoclass { EmpId = 3, Ename = "ragu" }
};
var empobj= from c in mygoObj orderby c.Ename select new{total= c.EmpId+c.Ename };
foreach (var item in empobj)
{
Console.WriteLine(item.total);

}

}

}
class mygoclass
{
public int EmpId { get; set; }
public string Ename { get; set; }
}
}