Connect Datacontrol to textfile

I need the exact code to link a text file or excel file to a data control.

assume the datacontrol is data1.
assume the textfile is located "C:\windows\desktop\myfile.txt"

I know how to do this with the property, but I want to set it at runtime.

Thanks!
thienAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
dabelleiConnect With a Mentor Commented:
   Data1.Connect = "Text;"
    Data1.DatabaseName = "d:\struct"
    Data1.RecordSource = "users#txt"

replace the d:\struct  by the path of the file
repale "users#txt"  with the name of your file  (keep the #txt)


0
 
thienAuthor Commented:
Thanks, can you tell me how to connect to excel, Thanks!
0
 
dabelleiCommented:
    Data1.Connect = "Excel7.0;"

Just change the connect type with the one you need, don't forget to mentionned the excel version.

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.