Solved

How do I fix "sqlconnection is undefined"?

Posted on 2010-09-14
2
528 Views
Last Modified: 2012-05-10
I was trying to rebuild a site and got the "undefined" error on a code-behind page. I guess I was in too much of a hurry. However, I have no idea where to start to fix the error. The "myCommand" statement receives the same error.  I use visual basic. Below is the code behind.


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim IDfromSession As String = (Session.Item("IDSession"))

        Dim myConnection As New SqlConnection("Data Source=vcnsql90.webhost4life.com;Initial Catalog=finaosms_membership;uid=************, pwd=*******************")
        myConnection.Open()

        Dim myCommand As New SqlCommand("uspGetTargetAddress", myConnection)
        myCommand.CommandType = CommandType.StoredProcedure

        myCommand.Parameters.Add("@LoginID", Data.SqlDbType.VarChar, 15)
        myCommand.Parameters("@LoginID").Value = IDfromSession

        Dim TargetAddress As String = myCommand.ExecuteScalar()

        Response.Redirect(TargetAddress, True)


        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 Comments
 
LVL 10

Accepted Solution

by:
himanshut earned 250 total points
ID: 33679236
Are you importing the proper namespace in you class:

"Imports System.Data.SqlClient"

0
 
LVL 18

Assisted Solution

by:Ajay Sharma
Ajay Sharma earned 250 total points
ID: 33679241
In the top of page declaration, import below namespaces:
Imports System.Data
Imports System.Data.SQLClient
 
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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

739 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