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!

Use Public Constant in ConnectionString Property

Status
Not open for further replies.

cnealy

Programmer
Feb 25, 2002
32
0
0
US
I declared a Public Constant in a .bas module.

Public Const iConnectionString As String = _
"Data Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\TCJPD\VB Project Files\Test_TCJPD_Data.mdb;" & _
"Jet OLEDB:Database Password=tcjpd"

Now I'm trying to use the constant as the connection string throughout the application. However, when I reference the constant in the properties window of an ADODC, the connection fails. Is it possible to reference a public constant from the properties window?
 
Check your Connection String

ADODC.ConnectionString = "driver={SQL Server};" & _
"server=bigsmile;uid=sa;pwd=pwd;database=pubs"
 
ConnectionString is fine. I referenced it in code, and it worked fine. The problem is using the Constant in the Properties Window of an ADODC.

For example, this works fine in code.
cn.ConnectionString = iConnectionString

However, if I type iConnectionString in the Properties Window for the ConnectionString property of the ADODC, I can't connect to the database.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top