简体   繁体   English

导入数据库连接文件

[英]import database connection file

I can't manage to connect to an SQL database using an external connection file 我无法使用外部连接文件连接到SQL数据库

I am getting an error which is something like namespace or type specified in the imports 'Pirelli.dbPirelli' does not contain any public member 我收到一个错误,该错误类似于namespace or type specified in the imports 'Pirelli.dbPirelli' does not contain any public member

Any idea how I can do this?? 知道我该怎么做吗?

Thanks!! 谢谢!!

Default.aspx.vb 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 - database connection file: 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

您需要以这种方式引用它

Imports YourProjectName.Pirelli.dbPirelli

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM