Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 executing an SP

Author  Topic 

mary_itohan
Posting Yak Master

191 Posts

Posted - 2007-05-28 : 06:44:49
Hi,
am new to asp.net and trying to execute a stored proceedure, am excecuting it on the button click event, in the code below, is this correct ???


Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim cmd As New SqlCommand()
cmd.Connection = conn
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "CustOrderHist"

' Create a SqlParameter for each parameter in the stored procedure.
Dim customerIDParam As New SqlParameter("@customerID", "ALFKI")
cmd.Parameters.Add(customerIDParam)

End Sub


Yes O !

mary_itohan
Posting Yak Master

191 Posts

Posted - 2007-05-28 : 06:52:56
I mean is this a good practice, tried searching the internet but didnt see any examples

Yes O !
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-05-28 : 07:22:54
Yes. It is fine. But where is the execute statement for calling this SP? Like cmd.ExecuteNonQuery or cmd.ExecuteScalar, depending on the type of your SP?

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -