Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2010-09-22
5
Medium Priority
?
594 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

Technology Partners: 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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

609 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