我想在项目中的任何位置使用dbConnectDBOStr
连接字符串,这样如果数据库连接发生更改,我只需要在一个文件中更改它
目前这是一个错误,任何人都知道我做错了什么?
请帮助我真的坚持这个谢谢!!
的Default.aspx
Imports Pirelli.dbPirelli
Partial Class _Default
Inherits System.Web.UI.Page
Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs) Handles MyBase.Load
Dim strCmd As String
Dim dbCmd As SqlCommand
Dim oConn As SqlConnection
Dim dbReader As SqlDataReader
oConn = New SqlConnection(dbConnectDBOStr)
dbPirelli.vb
Imports System.Data.SqlClient
Namespace Pirelli
Public Class dbPirelli
'Database Server - ENABLE ONE ONLY
Public Const strServerName As String = "[Server]" 'DEV
Public Const dbConnectDBOStr As String = "uid=[USER];password=[PASS];database=[DB];server=" & strServerName & ";Connection Timeout=60;"
End Class
End Namespace
此错误
描述:在编译为此请求提供服务所需的资源期间发生错误。请查看以下特定错误详细信息并相应地修改源代码。
编译器错误消息: BC30451: Name 'dbConnectDBOStr' is not declared.
来源错误:
Line 21:
Line 22:
Line 23: oConn = New SqlConnection(dbConnectDBOStr)
Line 24:
Line 25: oConn.Open()