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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Imports query

Status
Not open for further replies.

emozley

Technical User
Jan 14, 2003
769
0
0
GB
Hi,

In my code file I have a line:

Code:
Imports DataConnection

The word DataConnection is underlined in green and it says it can't be found.

I have a file called DbConn.vb which contains the following:

Code:
Imports Microsoft.VisualBasic
Imports System.Data.Odbc
Imports System.Data
Imports System.Web
Imports System.Configuration

Namespace DataConnection

    ''' <summary>
    ''' DataBase Connection Class.
    ''' </summary>
    Public Class DbConn
        Public connection As OdbcConnection
        Public ReadData As OdbcDataReader
        Public aCommand As OdbcCommand

        ''' <summary>
        ''' Data Connection and get Data Reader
        ''' </summary>
        ''' <param name="strQuery">SQL Query</param>
        Public Sub New(ByVal strQuery As String)
            Dim ConnectionString As String, connectionName As String

            'SQL Server DataBase Connection - Defined in Web.Config
            connectionName = "vfsos"

            ' SQL Server DataBase Connection - Defined in Web.Config
            ' connectionName = "SQLServerConnection";

            ' Creating Connection string using web.config connection string
            ConnectionString = ConfigurationManager.ConnectionStrings(connectionName).ConnectionString
            Try

                ' Creating OdbcConnection Oject
                connection = New OdbcConnection()

                ' Setting Conection String
                connection.ConnectionString = ConnectionString

                ' Open Connection
                connection.Open()

                ' get reader
                GetReader(strQuery)

            Catch ex As Exception
                HttpContext.Current.Response.Write(ex.Message)
            End Try

        End Sub
        
        ''' <summary>
        ''' Create an instance dataReader
        ''' </summary>
        ''' <param name="strQuery">SQL Query</param>
        ''' <remarks>Return type object of OdbcDataReader</remarks>
        Public Sub GetReader(ByVal strQuery As String)

            '  Create a Command object
            aCommand = New OdbcCommand(strQuery, connection)

            ' Create data reader object using strQuery string
            ReadData = aCommand.ExecuteReader(CommandBehavior.CloseConnection)

        End Sub
    End Class
End Namespace

What do I have to do to make the code file be able to see the DataConnection namespace?

Thanks very much

Ed
 
There is no DataConnection Namespace.
What functionality are you trying to import?
 
Hi,

I am trying to import the functionality contained within the DbConn.vb section of code I pasted in.

There is a line that says

Code:
Namespace DataConnection

Does this not create it?

Thanks very much

Ed
 


YOu need to include the root namespace of the project where the DBConn.vb file is located. If your project is named "TekTips" and the DBConn.vb file is located there, then the Imports statement should read:

Code:
[blue]Imports[/blue] TekTips.DataConnection

The root namespace defaults to the project name, but it can be edited in the project properties.


Mark

"You guys pair up in groups of three, then line up in a circle."
- Bill Peterson, a Florida State football coach
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top