hello sir,good morning

am creating one pos software ,i have done all my designing and coding its working fine in my system ,i kept my db in inside debug-->bin section but after created as a software application and when am using any other system it is showing the db path error ,last three months am searching for this pls do some needfull thank u.

This simply means your db isn't where the code thinks it will be. Compare the path of the file (or the relevant config file) calling the db against where the db actually is.
If you can, post up your project directory structure, that may help.
Of course, you have checked the db exists in your released projects right?

Public Sub CONNECT()

        CON.ConnectionString = "PROVIDER=MICROSOFT.ACE.OLEDB.12.0;DATA SOURCE=" + Application.StartupPath + "\BUYONLINE.ACCDB;"


    CON.Open()
End Sub 
Hi this is my connection string 

OK, you need to check Application.StartPath to make sure it is correct and then check the db file exists at the end location.

When i check my application startup path it shows the correct location d:\rathi\mypos\bin\debug 
but what is the problem

What is the exact text of the error? If you what you have described in correct there everything does indeed look like it should be working.

If I quote on your first post you said you kept your DB on Debug-->Bin am I correct?

You should put it on bin-->Debug where you will see the files and one is manifest that should solve your problem don't go to obj,x86,Debug that won't solve it. Also you can map it in your project using the project propertied and add it as resources.

how does one im[lement MvC pattern in the program using vb, the program name is student registration

@Inkandi please create a separate thread for that question as it is not related to the asked question here.

hello sir,
As you told it is in bin> debug > your Database then
and I know if you are running it from debug.
Then your DATABASE must be in same location as your Application location.
now the next question will be how to know where your application location
To know your app location use the following code

Dim location As String = Application.StartupPath()

the above code will show you the location of your folder where your executable file exist.

so you can use this to call your database

CON.ConnectionString = "PROVIDER=MICROSOFT.ACE.OLEDB.12.0;DATA SOURCE=" + location + "\BUYONLINE.ACCDB;"
    CON.Open()
End Sub()

I HOPE YOU GET YOUR PROBLEM.
Once again repeating your datbase file must be with your application file.

In Application.StartupPath() the exe file of the applicaion, which now you are tried to write, resides. Simply the path of the folder where the application exe file exists.
You can change the application startupPath. Put your database file into the folder where the exe file exists.
You can use following lines, if you like it.

Dim DataPath As String = IIf(Mid(Trim(Application.StartupPath()), Len(Trim(Application.StartupPath())), 1) <> "", Application.StartupPath() & "", Application.StartupPath())

Now, you can construct your ComnnectionString

CON.ConnectionString = "PROVIDER=MICROSOFT.ACE.OLEDB.12.0;DATA SOURCE=" & DataPath & "BUYONLINE.ACCDB;"

I am very very sorry. I made a great mistake to write the syntax. I forgot to write the "BackSlash" i.e.\.
The correct syntax is

Dim DataPath As String = IIf(Mid(Trim(Application.StartupPath()), Len(Trim(Application.StartupPath())), 1) <> "\", Application.StartupPath() & "\", Application.StartupPath())

@Santanu Das:
I am bit confused here.
Why you use Mid(trim.....))????
What the use of this here.

You can just call the File using the basic code then???

I am not saying you are wrong here, but I want to know what is the use of this here and how to use this.?

I just experianced the same problem when i was creating the drivers utility program. I think what should be done is that import your files as resources then call it using Resources because that embed the files within it, but the con of this is that if your files are separated by folders or are contained within the folders the import will not keep the folders but will only import the inside contants like .gif, .txt, .exe, etc.

I'm still facing the same problem on this project and the bad part is that mine has to be contained within the folders as there are certain files are located in folders so if I remove folders the drivers will fail to detect their associated files(resources).

I really don't understand why it cant embed the files even if I export it but it just don't carry these files. But as soon as I find a solution to this I will post it here.

@Deep Modi. Here I used the Trim() Function to truncate from both side, if there are any space resides with it. You can use it or not , its your choice. I tried there to complete the Path of the Folder where the database should be resided i.e. the applications StartUpPath. Now here I can simply add the database name.

Dim DataPath As String = IIf(Mid(Trim(Application.StartupPath()), Len(Trim(Application.StartupPath())), 1) <> "\", Application.StartupPath() & "\", Application.StartupPath()) & <DataBaseName>

Now we can use it build the Connection.

CON.ConnectionString = "PROVIDER=MICROSOFT.ACE.OLEDB.12.0;DATA SOURCE=" & DataPath & ";"

Thanks.

@ Santanu Das: thank you for explaining me, Can you just give me differnce between Your Code and mine code?
I need some example related to TRIM Function. CAN YOU? Please?

@MrM: I think you should Create program like software.
i mean You should add the importants files in the installation directory.

For example: Office, Office having all the theme and dll files in the installation directory so when you openn it will load all the files which are necessary ...

As you also have same problem as this thread.
You can use same coding. (I am not well understood with trim so i dont go for it right now.)

The best Way is to get with an example:
Let you create a simple program which contain the Richtextbox and having the Btn, menu etc. But you want to open the FILE.txt as program start or on btn click. if so you can access the File on the installation directory then you can by the simple code as below.

Dim location As String = Application.StartupPath()
' rest coding are not mention here.
Filelocation = location + "file_Name_With_extension.TXT"
' rest code...

If the above code is written in FORM LOAD event then file will open...
so with this simple code too you can access the file...

If this is not problem then you should create another thread with more details

@Deep Modi. I never say that you are wrong. But, I have used Trim() to make an extra prevention to restrict a Space() from both side. you can do it or not.
But, I do not understand why are you use a + symbol to concatinate two strings.
There are two symbol we can use + and & to concatinate two strings. The '+' never do the same. To concatinate two strings both do the same job. If you try to concatinate (not addition) of two numerical values using '+',System would be confused, it does not understand about it's work, it performs add operation i.e. 1+1 results 2, But, using '&' you can get as you desire i.e. 1 & 1 results 11.

Jea I know the use of

Trim()

But I think the OP's problem is the same as mine. Please read this carefully:

When you put files on an Application Startup Path the program will run fin when you run it within that path but copy it let's say to Desktop then it won't function because the files that you added are not contained within the application or the exe file so what I think may solve this is to maybe create a cab file and put inside the files then when calling it start by calling or try to open the cab file first then call the function to open the files. I haven't tried this yet because I'm not in front of my laptop but once I get home will try this idea and see if it works. The cab file must be included as Resources

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.