Solved

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

Posted on 2010-09-22
5
507 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 142

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 142

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
call function 8 40
Gridview User Control event not firing 4 45
How to trouble shoot .net contact form 3 31
Jquery autocomplete 10 30
I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video discusses moving either the default database or any database to a new volume.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now