954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

remote accessibility

I have been asked to buid a VB code which is flexible.Wen i take project from
one place to another,i need not change path in all forms.If i change in one
place,then it gets reflected in all other forms.
ex:In com1,I hav path=e:\proj\a1.MDB which I use in al the forms;
& in com2,I need to change the above path such tat I need to change it only once.
Can I assign the whole path to a variable and declare the whole thing as global??
Is it possible to write
data1.ConnectionString = App.Path + "db1.mdb"
If so where do I define App.Path??
I am new to VB6.pl help

kartik07
Light Poster
29 posts since Dec 2007
Reputation Points: 10
Solved Threads: 0
 

Hi karthik,
yes you can use app.path ti resolve your connection problem,
we can use it from where ever you need, it takes the application folder path as App.path
that is your Database should placed on the folder where you placed your application.
With addition use can use Subfolder names for example
Quiz is Your application folder name,you placed your Database in the Subfolder "Data"
D:\Quiz\data
in this case
ucan use

App.path & "\Data\Db1.mdb"


unless the palce the Db in Application folder itself and use your code App.path & "\Db1.mdb"

I hope this will help you

With regards
Venkatramasamy SN

venkatramasamy
Junior Poster in Training
71 posts since Aug 2007
Reputation Points: 12
Solved Threads: 12
 

OK....but where should I define App.path???

I want to define it only once.so do i need to declare it an any of the forms or do i need
to declare it as public or something.Sorry,I am not familiar with Syntax.

kartik07
Light Poster
29 posts since Dec 2007
Reputation Points: 10
Solved Threads: 0
 

Hi Karthik

Use module
and define it in the module,
yo cann access the module from anywhere

With regards
Venkatramasamy SN

venkatramasamy
Junior Poster in Training
71 posts since Aug 2007
Reputation Points: 12
Solved Threads: 12
 

k.thanks.illl try tat...thanx a lot

kartik07
Light Poster
29 posts since Dec 2007
Reputation Points: 10
Solved Threads: 0
 

k.and do i need to connect the module with something???

kartik07
Light Poster
29 posts since Dec 2007
Reputation Points: 10
Solved Threads: 0
 

HI,i tried using a module but it is showing
compile error:invalid outside procedure.

kartik07
Light Poster
29 posts since Dec 2007
Reputation Points: 10
Solved Threads: 0
 

Hi karthik,
In the module write your code in function
the funcation can be accessed from anywhere in the project by using Mudulename.functionname
for example]
Your module name is DBCon
And Functionname is Connection
The code to access the function is
[code]
DBCon.Connection
[\code]

Hope this will help you

With regards
Venkatramasamy SN

venkatramasamy
Junior Poster in Training
71 posts since Aug 2007
Reputation Points: 12
Solved Threads: 12
 

hi venkat,
I am really sorry.I dont mean to irritate u.is func syntax something like this??
type def
App.Path = "E:\LATEST"
end type

kartik07
Light Poster
29 posts since Dec 2007
Reputation Points: 10
Solved Threads: 0
 

ok,
then you must place/paste your project in the "E:\LATEST" location in which system you are using ther with, if the problem still exists, kindly send me the details of the sequence details from begining what you do , what you get and what you want

with regards
Venkatramasamy SN

venkatramasamy
Junior Poster in Training
71 posts since Aug 2007
Reputation Points: 12
Solved Threads: 12
 

wel i used the following code in al the forms
Data1.DatabaseName = App.Path & "\ATMDB.mdb"
It is working but after unloading it shows some
compilation error

kartik07
Light Poster
29 posts since Dec 2007
Reputation Points: 10
Solved Threads: 0
 

Hi,
Why you failed to notify the error and let me ask you the error details, just directly post all error details getting ok,

then only we can understand your problem in right path,

With regards
Venkatramasamy SN

venkatramasamy
Junior Poster in Training
71 posts since Aug 2007
Reputation Points: 12
Solved Threads: 12
 

App.Path is Read Only and is set to the path of the executable file. You shouldn't define this anyway, as a user may chose a different path when installing the program. You can use like App.Path$ & "\Data\MyFile.MDB" and your program will the data directory no matter when the user installed your program.

SCBWV
Junior Poster
125 posts since Apr 2007
Reputation Points: 40
Solved Threads: 24
 
hi venkat, I am really sorry.I dont mean to irritate u.is func syntax something like this?? type def App.Path = "E:\LATEST" end type

App.Path is a built in value stemming from the prewritten function 'App.'

App.Path should be used on the right hand side of the '=' operator: not on the left hand side like you have it.

Dim strPath as string

strPath = App.Path


Your program should have a default installation path. Microsoft recommends using the 'Program Files' Directory and then the name of your program: e.g. c:\Program Files\My Application\

If you want to change the path your program uses, that type of information should go into your registry:

Option Explicit
Dim strStartUpPath as string
strStartUpPath = APP.path  
' Or
strStartUpPath = strMyChoice

Private Sub Form_Load()
strStartUpPath = GetSetting("MY APP", "Install Defaults", "StartUpPath", "C:\Program FIles\My App")


End sub
hkdani
Posting Pro in Training
435 posts since Nov 2007
Reputation Points: 49
Solved Threads: 47
 

hi,
thanx a lot..I got the answer..ill try this also..

kartik07
Light Poster
29 posts since Dec 2007
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You