Visual basic error

What is the error in this code?

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Private strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _ "C:\Documents and Settings\reid\Desktop\BSN Home.mdb;"

I get an identifier message about the underscore next to the ampersand above - what shouod I change it to?
       
Dier02Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Ryan ChongConnect With a Mentor Commented:
try:

Private strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\reid\Desktop\BSN Home.mdb;"
0
 
EncognitoConnect With a Mentor Commented:
you may be able to change & to + if thats the problem
0
 
Wayne Taylor (webtubbs)Connect With a Mentor Commented:
ryancys' correct. The underscore is used when splitting code over multiple lines. If all the code is on the one line, the underscroe is not needed.

Wayne
0
 
Pratima PharandeConnect With a Mentor Commented:
Private strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "C:\Documents and Settings\reid\Desktop\BSN Home.mdb;"
0
 
andrewneelyCommented:
try using dim instead of private inside subproceedures.  Private can be used at the class, form or module levels, but not at the subroutine level
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.