Using variabel in my connectionstring

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
 
P

Piet Linden

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
 
S

Stuart McCall

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 & ""
 
A

alvin Kuiper

Hi Stuart
Well it is a string
I have public data as string ??

alvin

"Stuart McCall" skrev:
 
Top