Solved

'Execute' is not a member of 'System.Data.SqlClient.SqlCommand'

Posted on 2010-09-22
5
531 Views
Last Modified: 2012-05-10
I am trying to execute a Stored Procedure from my code-behind page and I get the error:
'Execute' is not a member of 'System.Data.SqlClient.SqlCommand'

The SP is to be executed when the button "GetTeachers" is clicked.

Below is my code. Can you help me find out what I'm doing wrong?  

I use VS2008, SQL Server 2008, Visual Basic

Thank you.

Partial Class Application_episd2_SchoolAdmin_RptAdminSelStdntSelTeachSelIntType
    Inherits System.Web.UI.Page

    Protected Sub GetTeachers_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles GetTeachers.Click
        Dim SID As String = TxtBxSID.Text

       Dim myConnection As New SqlConnection("Data Source=vcnsql90.webhost4life.com;Initial Catalog=*************;uid=****************;pwd=**************")
        myConnection.Open()

        Dim myCommand As New SqlCommand("uspTeachersOfIndvStdnt", myConnection)
        myCommand.CommandType = CommandType.StoredProcedure

        myCommand.Parameters.Add("@SID", Data.SqlDbType.VarChar, 10)
        myCommand.Parameters("@SID").Value = SID

        myCommand.Execute()

    End Sub
End Class
0
Comment
Question by:bobbellows
  • 2
  • 2
5 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 33734035
use ExecuteNonQuery
0
 

Author Comment

by:bobbellows
ID: 33734140
So, would the command be:

myCommand.ExecuteNonQuery ()

0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 33734271
yes, exactly
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 33734354
ExecuteReader, ExecuteNonQuery, ExecuteScalar ... When to use What ?
http://blogs.x2line.com/al/archive/2007/05/01/3049.aspx
0
 

Author Comment

by:bobbellows
ID: 33743757
Angellll,
I just got pulled to another project. When I can get back to this one, I'll try this out and let you know how it went. Thanks
Bob
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question