[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How do I fix "sqlconnection is undefined"?

Posted on 2010-09-14
2
Medium Priority
?
534 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 1000 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 1000 total points
ID: 33679241
In the top of page declaration, import below namespaces:
Imports System.Data
Imports System.Data.SQLClient
 
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

650 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