Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 645
  • Last Modified:

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

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
bobbellows
Asked:
bobbellows
  • 2
  • 2
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
use ExecuteNonQuery
0
 
bobbellowsAuthor Commented:
So, would the command be:

myCommand.ExecuteNonQuery ()

0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
yes, exactly
0
 
DhaestCommented:
ExecuteReader, ExecuteNonQuery, ExecuteScalar ... When to use What ?
http://blogs.x2line.com/al/archive/2007/05/01/3049.aspx
0
 
bobbellowsAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now