Home | Articles|Namespace|Interview Questions|Tools|Jobs|Projects|Community
Asp.net Tutorials

»Dotnet Ads
»Message Boards
Message Boards
Dotnet Books

»Member Details
Register
Login
LogOut
Submit Code
Submit Jobs
Submit Projects

»Competition
Community
Winners
Prizes
Write For Us
Members

»Other Resources
Links
Dotnet Resources

Stored Procedures a simple understanding

Writing sql queries is quite common and simple in codebehind in asp.net and other languages




writing stored procedures and calling them has many advantages




Casually, you would call a database with a query like:

Select empname From tblemp

to write a stored procedure

just do like this



CREATE PROCEDURE chandu
AS
Select empname From tblemp
Go


so we have created a stored procedure chandu now

so simple right ..? hehehe


lets create another stored procedure called latha now
ok ?


CREATE PROCEDURE latha
AS
Select name,rollno from tblgokaraju
Go



done we created a stored procedure called latha also

we are great upto here

now how to call that ???


its so simple just call it by its name enough

latha is simply enough to get it executed....

too great upto here

lets call it in a asp program
dont worry asp and asp.net are similar while calling stored procedure ...




dim Con, Sql1, rs
set Con = Server.CreateObject("ADODB.Connection")
Con.Open "DSN=webData;uid=user;pwd=password" 'make connection
Sql1 = "latha"
Set rs = Con.Execute(Sql1) 'execute sql call





here just i used sql1 to call stored procedure latha

hehe ....

hows stored procedure so simple right?


now i will give u a query think how to write stored procedure for that.....

select * from latha where id=1226

common think this

in such situations see this

CREATE PROCEDURE latha
@x int
AS
Select name,rollno From Tblstudent
Where rollno = @x
Go



so simple right?

@ x as some datatype is 1st point
calling that again like see here rollno =@x


executing stored procedure is

latha 1226

enough u r work is done
how this ?

lets see with more

CREATE PROCEDURE chandu
@x int,
@y varchar(100),
@z
AS
.....
Go


executing that

chandu 0, 'Latha is my best friend', 12.26


in code we do parameter passing values based ones like this in asp(similar in asp.net

Have a Question and dont know the answer post it below and get answers in minutes

Due to spam this feature is disabled
To get answers fast , make sure you enter a detailed subject for example: "DataGrid issues need answer" not "DataGrid"

Subject:

Catjegory Name:

Message:



© 2008 dotnetwatch.com -- Privacy policy

Website Design & Internet Marketing by Shivam