?
Solved

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

Posted on 2010-09-22
5
Medium Priority
?
572 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

752 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