Using variabel in my connectionstring

  • Thread starter Thread starter alvin Kuiper
  • Start date Start date
A

alvin Kuiper

Hi
I try to use this:

data = "c:\brugere.mdb"

Const Forbindelsesstreng = "Provider=Microsoft.Jet.Oledb.4.0;" & _
"data source= " & data & ""

But get a error, why ?
Can someone help here?

Alvin
 
Hi
I try to use this:

data = "c:\brugere.mdb"

Const Forbindelsesstreng = "Provider=Microsoft.Jet.Oledb.4.0;" & _
"data source= " & data & ""

But get a error, why ?
Can someone help here?

Alvin

Because you can't use a constant like a variable. A constant has a
_constant_ value (it cannot change). So, you need to change your code
a little

Const Forbindelsesstreng = "Provider=Microsoft.Jet.Oledb.4.0; "
Dim strDataSource As String
Dim strFullPath As string

strDataSource = "c:\brugere.mdb"
strFullPath = Forbindelsesstreng & strData
 
alvin Kuiper said:
Hi
I try to use this:

data = "c:\brugere.mdb"

Const Forbindelsesstreng = "Provider=Microsoft.Jet.Oledb.4.0;" & _
"data source= " & data & ""

But get a error, why ?
Can someone help here?

Alvin

Forbindelsesstreng would need to be a string variable for this to work:

Dim Forbindelsesstreng As String

data = "c:\brugere.mdb"

Forbindelsesstreng = "Provider=Microsoft.Jet.Oledb.4.0;" & _
"data source= " & data & ""
 
Hi Stuart
Well it is a string
I have public data as string ??

alvin

"Stuart McCall" skrev:
 
Back
Top