Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reference error in a vb code that calls stored procedure

Status
Not open for further replies.

cmsbuffet

Programmer
Feb 3, 2009
173
CA
The following code gives an error on every single line of code.

Code:
Imports System.Xml
Imports System.Xml.XmlReader


Dim SQLXMLReader As XmlReader

        SqlCommand.CommandText = "GetZipcodesForDistance"
        SqlCommand.CommandType = CommandType.StoredProcedure
        SqlCommand.Connection = New SqlConnection("Data Source=ANASTASIA-PC\SQLEXPRESS;Initial Catalog=ZipCodeAndDistance;Integrated Security=True;Pooling=False")
        SqlCommand.Parameters.AddWithValue('@OriginalZipCode', Me.TextBoxZipcode.Value)
        SqlCommand.Parameters.AddWithValue('@Distance', Me.distanceTextBox.Value)

        SqlDataReader = SqlCommand.ExecuteReader()

        SQLXMLReader = SqlCommand.ExecuteXmlReader()
        While (SQLXMLReader.Read)
            Page.Response.Write(SQLXMLReader.ReadOuterXml())
        End While

Error
Reference to a non-shared member requires an object reference.

What does that error mean and how to fix it?
 
You'd probably be better off asking this in forum796 (but essentially you can't use a class name - SqlCommand - like this; you need an instance of it so something like

Dim mySqlCommand as New SqlCommand

and then use mySqlCommand wherever you are currently using SqlCommand)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top