导入数据库连接文件

时间:2014-03-12 15:59:55

标签: asp.net vb.net database-connection

我无法使用外部连接文件

连接到SQL数据库

我收到类似namespace or type specified in the imports 'Pirelli.dbPirelli' does not contain any public member

的错误

知道我怎么能这样做吗?

谢谢!

Default.aspx.vb

Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.Common.DbDataReader
Imports System.Web.UI
Imports System.IO
Imports Pirelli.dbPirelli


Partial Class _Default
    Inherits System.Web.UI.Page


    Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)

        Dim cmd As New SqlCommand
        Dim SQLdr As SqlDataReader        'The Local Data Store

        cmd.Connection = dbConnectDBOStr


    End Sub

dbPirelli.vb - 数据库连接文件:

Imports System.Data.SqlClient


Namespace Pirelli


        Public Class dbPirelli
            Public Const strServerName As String = "testserver"  'DEV

            Public Const dbConnectDBOStr As String = "uid=[MYIDHERE];password=[MYPASSHERE];database=[DBNAMEHERE];server=" & strServerName & ";Connection Timeout=60;"

        End Class

    End Namespace

1 个答案:

答案 0 :(得分:0)

您需要以这种方式引用它

Imports YourProjectName.Pirelli.dbPirelli