Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Get The Path Of An Access Database From The Database Object?


If I use the following code to open a database in a code module:
Code:Function ConnectMDB(dbPath As String, dbName As String, objTmpDB As Database) As Boolean
    On Error Resume Next
    Set objTmpDB = OpenDatabase(dbPath & dbName, _
        Connect:="Driver={Microsoft Access Driver (*.mdb)};" & _
        "Uid=Admin;Pwd=;")
    If Err.Number = 0 Then
        ConnectMDB = True
    End If
    On Error GoTo 0
End Function


And call it using:
Code: If ConnectMDB(dbPath, dbName, dbKB) = False Then

Can I later get the system path of the database file from the object "dbKB"? Reason: I use the dbKB object thruought my userform which is loaded much later, but I need to know the path of the database without creating an additional userform property.

|
+--JDMils
|
+--VB6
+--VB Dot Net
|
+-- Navman GPS Forums @ http://forum.jdmils.com
|




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Path To Access Database
Hi All,
Can anybody tell me how to set the path to my access database (linked to my data control) to the same directory that the compiled exe is run. Dont know if I explained that one well enough.
Basically my problem is that I attach the database to the project but it still looks for the database in c:.........whatever.mdb. The installation installs the database to wherever the user specifies in the install (usually c:program files......).
Simply I want to set the current working directory to the directory where the .exe is being run from.
Thanks alot.
R.

Access Vba Database Path
I'm new to vba and have started using the following code in some of my form code:

Dim strAppPath As String
Set strAppPath = Application.CurrentProject.Path

I'm thinking it would be better to set strAppPath as a Public Const but I'm not sure where or how to do it. I tried to do it in General Declarations using:

'bad code
Public Const strAppCode as String = Application.CurrentProject.Path

That's not the way but I need to know what the "right" way is.

Access Database Path
Hello Everyone!!

I used access database with vb.
But in connection string i have given path like :
c:project1db1.mdb

and when i install it on other pc at differnt location it gives invalid path error.
So can i build a s/w without perticular path restriction to user ?

Restore Ms - Access Database Backup Taken On A Cd Into App.path
Hi,

My Appln. Requires Backup On A Cd. For Taking A Backup I'm Using File Scripting Object But Unable To Take It On A Cd. Any One Of U Gurus Out Here Pls. Help Me To Take A Backup On A Cd From App.path And Restore It Whenever Required.

Pls. Help Me Out. I'm Stuck At Filecopy . There It Gives Me An Err Saying Path Not Found.

Crystal Report Working With Runtime Relative Path Of Access DataBASE
   I am Amit , Sys. Analysis , We r working in Vb last 3 years with Data reporting . Now we have to shift our projects to Crystal REPORTS 8 .

Tell Me How Can I Design Reports Using Without using Absolute Path of Access .mdb Database File i.e c:
ew.mdb or d:
ew.mdb .

At SETUP Time , User can Select Different Location tnhen these CR Reports Can not Work due to Absolute PAth at design time . HOW WE CAN DEFINE PATH OF DATABASE AT RUN TIME of CR8 or VB .Like (App.Path)

    ...... Please Reply ASAP.

--AMIT

Inserting OLE Object In Access Database Using VB
I have been trying to insert a picture(an embedded OLE Object) in a field in my Access Database. I have tried everything and nothing has worked. I really do not know how to proceed.
Any idea?

Gbola Ifaturoti

How To Programmatically Insert An Ole Object Into An Access Database
I am working on a VBA program in MS outlook in which I am using an ADO connection to update an Access database. It works fine for my text fields, but I am not sure how to update an Embedded Object field. Anyone know how I can do this?



For example I have a database called C:/Test.mdb with table "My_Table" containing a field called "Email_Message" (data type OLE Object). I would like to insert the current Mail Item in my ActiveExplorer window into the "Email_Message" field in the database:

Function LogEmails()
    Dim msg As MailItem
    Dim rs As New ADODB.Recordset
    Dim cn As New ADODB.Connection
    Dim strSQL As String
    Dim FilePath As String

    Set msg = ActiveExplorer.Selection.Item(1)
   
    FilePath = "C:Test.mdb"
    Set cn = New ADODB.Connection
    With cn
        .Provider = "Microsoft.Jet.OLEDB.4.0"
        .ConnectionString = "data source=" & FilePath
        .Open
    End With
    Set rs = New ADODB.Recordset
    strSQL = "UPDATE My_Table SET Email_Message = " & msg & " WHERE Item_ID = 2"
    rs.Open strSQL, cn
    Set rs = Nothing

End Function



Thanks,

Dudeman

I Am Getting A Compile Error Using A Database Object In VBA (with Access)
I am fairly new to MS-Access and VBA coding. I am trying to write a routine in VBA code to parse the records in a table. I found an example that uses a Database Object and it looks like this might be a good way for me to implement this; however, I am getting a Compile Error - Invalid use of Property on the assignment of my Database Object (db) to CurrentDb().

Here is the code:

Dim db As Database
Dim rs As Recordset
Dim strSQL As String
Dim myCount As Integer
Dim rsCount As Integer

db = CurrentDb()
strSQL = "SELECT InventoryControlNumber from InventoryItems"
rs = db.OpenRecordset(strSQL)
rs.MoveLast
myCount = rs.RecordCount
rs.MoveFirst
For rsCount = 0 To myCount - 1
Debug.Print (rsCount)
Debug.Print (rs.Fields(0))
Debug.Print (rs.Fields(1))
Debug.Print (rs.Fields(2))
Debug.Print (rs.Fields(3))
Debug.Print (rs.Fields(4))
Debug.Print (rs.Fields(5))
rs.MoveNext
Next rsCount

' Close recordset
rs.Close
db = Nothing

I appreciate any assistance that can be provided.

FYI:
Here are the current Visual Basic References that I have checked:

[X] Visual Basic For Applications
[X] Microsoft Access 9.0 Object Library
[X] OLE Automation
[X] Microsoft ActiveX Data Objects 2.1 Library
[X] Microsoft DAO 3.6 Object Library
[X] Microsoft Office 10.0 Object Library


I am using Microsoft Access 2000 (9.0.6926 SP3)
with Visual Basic 6.0


Also....
I tried changing CurrentDb() to CurrentDB
with no parenthesis - same error.
I tried specifying DAO in my variable declarations:
Dim db As DAO.Database - same error.


Thanks,
Bill

Storing An Embeded Word Object Into An Access Database
I have a utility which uses OLE to open a MailMerge Document, Merge it to a new Document and Print it. Without writing the newly merged document to the disk, is it possible to save the document into an Access Database in a LongBinary Field? I have investigated the Appendchunk method but this does no seem to be applicable for the embeded object...

Import Excel Spreedsheet As OLE Object Into Access Database
Hi, all the experts

I am trying to embedded excel into access record, i want to know if it is possible, I searched on google but didn't really see much info about it..
please help ..

I attached the sample database i am trying to build.

I have a table with field, ID, Name, File(OLE Object), and a form when click on the button access will insert a record into the table.
 

Access To An Oracle Database Via ODBC With A COM-Object Service Ordered By An ASP
For my diploma theses I am developing a client-server Application.
With the server component (COM) - developed in VC++ -I access to an Oracle database via ODBC.

OS =Win2000

When the client is a VBScript-File or a C++ application there is no problem.

But now I want to order Services from my server component via an Active Server Page (ASP).

The server comonent terminates irregularly without jumping in the catch block. With an error trace I have located the termination while instancing the database object with:

„CDatabase::Openex("DSN=BeUserPr Oracle;PWD=musterpwd;UID=musteruid",
CDatabase:penReadOnly);“

Is it perhaps an ODBC Driver problem (I am using the newest Oracle ODBC driver!!!)

Who knows a solution for my Problem?


Gabi

Exporting Data From One MS Access Database To Another MS Access Database In Visual Basic
hello friends,
i want to transfer the data from one Access database to another Access database using visual basic.

The first Access Database name is Data1
Table Name is tbldata1
fields - ID -- Number
            venueID -- Number
            Date --- Date/Time
            RNo --- Number
            SRNo --- Number
            HNo --- Number

i want to transfer this data into the second Access Database -- Data2
with table name same & fields also the same

pls can anyone help me out with this problem

Regards
Girish

Calling An Excel Macro From An Access Database That Refers To That Database
hi

i have a macro in excel that inserts some values into a table in a database in access, but i want to make it so i dont have to touch the excel file, instead i have a module in the access file that calls the sub in the excel file, but then i get an error saying that the database is already open....is there a way of getting around this?

thanks

jimmyp

How To Link Remote MySQL Database To Local Access Database?
i try to create Access DB, and link some tables from remote MySQL DB to this local DB.

it's very easy to do it manually.
could any one tell me how to do it in VB program?
Thank you so much!

How Do I Copy A Database Object To Another Database?
Greetings everyone,

I have two Microsoft Access databases A.mdb and B.mdb.
(currently using Access 2003)
I would like to programmatically, using Visual Basic, copy
a database object from database A.mdb to database B.mdb.

I'm using the term Database Object to define a:
Table, Query, Form, Report, or Module.

Database A.mdb is behind a firewall on a local area
network and connected to the internet using DSL.


(example url)
Database B.mdb is located at service provider
http://somedomain/databasefiles/A.mdb


Is there a way to do this?
If so what would be the code to perform that action?

Please consider that my goal is to mimic this functionality:

If both databases resided on the same machine and I
had both open to where I could see both Database
Windows open and I dragged a report object from database
A.mdb’s Database Window into database B.mdb’s Database
Window a plus sign would appear indicating that I was about
to copy that Report Object. As soon as I release the mouse
button the object would be copied to the other database.

That’s exactly what I am trying to do programmatically.

I originally tried using the DoCmd.Transferdatabase method, a command that I have used before with great success with copying objects but unfortunately it does not allow for the database name to have http:// at least from what I can been told.

Any help would be greatly appreciated.

Unrecognized Database Format &"Path To Database...&"
Im not sure what I did wrong, but I keep getting this error when I run my VB program. I am attempting to write a Search program for an Access database and I am failing miserably.

Any ideas?
-Matt

Transferring VB Project From Access Database To SQL Server Database
Hello,

I have been working on a project at my employer to bring a current program that is run by a third-party company, in-house so that we can run it ourselves instead of paying out monthly fees to the third-party company.

The basics of the program are fairly simple. However, after getting the code about 90-95% done, I am realizing that my Access database will quickly become too small to use. I know we have SQL Server on at least one of our servers, and am thinking about trying to use that instead of Access.

My question is, how hard would it be to transfer my project to a SQL Server database instead of an Access database? I am using ADO to connect to my Access database right now. Would I have to make any adjustments to my VB code? I realize some of the SQL in the code will need to be adjusted, but what about my cn. and rs. lines of code (connections and recordsets)?

Shame on me for not realizing Access's size limitations before now. Any information that anyone can provide is greatly appreciated. Thank you in advance.

Convert Access Database To Works Database Via Code?
Does anyone know of a way to convert an access 2000 database to a msworks database via VB6 code? ANY suggestions are welcome. TIA.

How To Import MySql-database Table To Access-database
I'm building a client-database in .NET for my work and I'll have the program copying rows of data from the online MySQL-database to a local offline Access-database. Everything looks alright when opening the local database in Access but when opening it in my app I get an error saying that the index or primary keys will conflict because of duplicates. I have tried endlessly to switch primary keys, creating new ones but nothing seems to help. Any suggestions?

Compating Database... How Do I Set The Path With App.Path?
this is my code I have but i get an error. It changes the path name of where my database is. I have a connection to 2 different databases in this form and some reason it gets the path for the other database +databaseWMdbase.mdb

so it shows up like this.

C:MYProgramPastOrdersdatabaseWMdbase.mdb


all I want it to do is go here

C:MYProgramdatabaseWMdbase.mdb

I tried using app.path but it puts app.path in the file name... I don't know what the deal is...
--------------------------------------------------------------------------------

Me.MousePointer = 11
'declare variables
Dim objJRO As JRO.JetEngine
Dim strConnSource As String
Dim strConnDestination As String

'set connection string info
strConnSource = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=databaseWMdbase.mdb"
strConnDestination = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:Temp.mdb"

'instantiate object
Set objJRO = New JRO.JetEngine

'compact database from source to destination
objJRO.CompactDatabase strConnSource, strConnDestination

'release objects
Set objJRO = Nothing
Me.MousePointer = 0

FileCopy "c:Temp.mdb", App.Path + "databaseWMdbase.mdb"
Kill "c:Temp.mdb"
Killcn CN

SQL Database To Update Access Database
Hi

I have to create a VB project that goes to a remote SQL server and passes any updates to a mailing list into an Access database on a local machine. Im not sure how to do this. I worked on creating a dataadapter, but Im not sure how to pass this over so it can be inserted into the Access database. Also should I use OLE DB for the connection of both? And if I create an exe file would the computer that uses the application have to have the .NET framework installed?
The 2 databases are set up differently so I would have to get only certain fields from the SQL database and I would have to limit the information to only include data where the an update has occured (using a date stamp field).
Any ideas on the best way to do this? Thanks for any advice.

Database Path?
i am trying to make my program see an access database without specifying the full path name. I want to put an relative path name and preferably put them in the same folder, so i can burn it onto cd and people can run it without having to change the drive name.

Database Path
I want that when my program runs it should first check the database. If the database exists its. and if not it should open a dialog box asking the lcation.
I have done the first portion i.e checking the database. I want to know how can i browse through my drive and to get the file. like open option in any window application.

Database Path
I was just wondering, but could you find the path of a certain database through the DSN? If so, How? Thanks for any help.

"And the day shall come when the Viper will take his throne"

Database - App Path
i had written my whole database app with the path pointing to c: somewhere, and i now want to change it to where the app is!

can i have the codes please and the changes i need to make?

thanks

Database Path
hi there

i have a program that i have created that is connected to a database i want to create and exe so i can run it on a friends computer i have burned the exe and the database on to a cd but i have found i can not open it because it can not find the database because of the specified path is incorrect is their anyway that i can run the program and have my program find my database on the cd

this is the path i have used

sconnect = "provider=microsoft.jet.oledb.4.0;data source = D:/video/video master/video/video1.mdb"

Database Path
HI!. in my connection i have this line of code

VB Code:
MyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;data Source=\NetServerDbaseDatLibrary.mdb"


If i make the project .exe and install it in a computer where the name of the server is not 'NetServer' the program will not run properly.

is there a way to make the path dynamic?

Database Path
hmmm... If you are calling the report file from within your application, use the App.Path to indicate the path of the mdb file.

.

Path Of Database
is there anyway where i can make it find the database file without c:and path iw ant to be able to have the word
data.mdb
instead of having to do
c:desktopdata.mdb

THANKS

Path Of Your Database?
how can i specify where my database is if i put it on other computers, there must be something like
data1.path = me.path

or something like that.. any suggestions?

Thanks,
Tobyn

How To Get The Path Of A Database
Sorry if this question has been asked a million times already. I searched the forum, but couldn't find a suitable answer.

I need to get the path of my database in VBA. It seems really easy to me, but being a VBA newbie, I can't figure it out.

Help appreciated, Frans

Path To Database
I am packaging and deploying my first VB6 app.

I will be installing the app on a remote server and don't want to have to redefine the path to my database in all the adodc objects I used. Is there a way of having the database generically always be in the same path as the application itself so that I don't have to change all of these before running the program at my client site.

Hope this makes sense.

Kindest regards


Ian Cook

Database Path
Hi,

I'm connecting to MS Access database using DSN (RDO Connection). I want to know the database path to perform some other tasks in the same directory where database resides. How can i get the directory path or database path Programmatically.

Thanks in advance
Basha

Database Path
I have a VB application that runs on a client computer and the Access database for the application is sitting on a server. The system is networked and I have a map drive to the database on the server which is a shared file. That mapped drive is coded into the application to gain access to the database. I am having some problems accessing some of the reports on the Access database and in my troubleshooting I want to try to write a message out that would tell me what path it is accessing when it goes to the database for information. I tried using App.Path but that only gives me the path of the application on the client machine. Is there a command or function that could read the networked database path and tell me what my program is really trying to access?
Thanks
Kim

Specify Database Path ?
I've my database in d:s.orangzebworkcafemanagerusers.mdb now when I creat an exe file and start another windows ( windows me ) it says "Runtime error 91 no object variable or block with set" I think it couldn't find database. What the code will be of setting the path of database. for example dsn=app.path & users.mdb.Thanx

Database Path
I have a VB application that runs on a client computer and the Access database for the application is sitting on a server. The system is networked and I have a map drive to the database on the server which is a shared file. That mapped drive is coded into the application to gain access to the database. I am having some problems accessing some of the reports on the Access database and in my troubleshooting I want to try to write a message out that would tell me what path it is accessing when it goes to the database for information. I tried using App.Path but that only gives me the path of the application on the client machine. Is there a command or function that could read the networked database path and tell me what my program is really trying to access?
Thanks
Kim

Database Path
hello
i am trying to open database connection with the help of adodc using the following code:

conn.ConnectionString = "provider=microsoft.jet.oledb.3.51;" & "data source=App.Path &
esults.mdb"

it shows the invalid path message. If i give complete path instead of using App.path then it works fine.But i want to use App.path.Please suggest me the correct formatting.
Thanks
smriti

Database Path From DSN
Is there a way to read Database path from ODBC User DSN settings.

Database is configured and I have its name.
Thank you

Storing Path In A Database
Hi,

I'm storing a picture path in a database but i'm saving it like:

c:picturesxx.bmp

i NEED

\serverpicturesxx.bmp

Thanks

Selection Of Database Path [HELP...]
I would like to let the user to select the database path. Once the user select the database path. He doesn't need to select the database path again. How can I do this?

Securing Database Path???
i am writing an application that will be run on a lan.

i am accessing the database with a connection string like
\sharedatabasepathdatabase.mdb

is there any way to secure this path so that no one gets access to the database on the network, apart from my software....


any better ideas would be very helpfull

Thanks alot

Database Path Question
Hello,

When using sp_attach_db, where is the actual path stored for the associated database?

I know that in the registry it stores:

Currently attached databases
HKEY_LOCAL_MACHINESOFTWAREODBCODBC.INI

DSN List
HKEY_LOCAL_MACHINESOFTWAREODBCODBC.INIODBC Data Sources

Thanks very much!

Problem With Database Path
I am doing a database project with access 2000. while declaring the ado object i have to specify the path and the name od the database. this limits my deploying solution. 'cause i have to install my program on the specified drive and directory. can I declare the path ala in setup scripts "<installDir>"?

Opening A Database With App.path
I have tried to open a database with app.path and am getting an error. It looks like it is just looking within the VB folder. Is there something I should know? Here is code:


Dim db As Database
Dim rs As Recordset


Private Sub cmdRun_Click()
Set db = OpenDatabase_ &(App.Path& " echheadsdatabase_2.mdb")
Set rs = db.OpenRecordset(Customers)
rs.MoveLast
rs.MoveFirst
For i = 1 To rs.RecordCount
picBox.Print db(LastName)
Next i
End Sub

Database Path At Run Time
How can i specify the path of my database at rutime

Invalid Database Path
Ok whilst making my App I used the following directory for my database:

D:My ApplicationsJob Database.mdb

After I have made the Install Shield it works fine but when I installed it on a mates computer it still thinks the database is on that file path.

Is there a way to tell the App that the Database located is where the App has just been installed?

Eg

My Computer: D:My ApplicationsJob Database.mdb

Mates Computer: C:My DocumentsJob Database.mdb

So it automatically picks up the different file paths and allows for it to be used.

Database Path From .txt File ??
Hello...

I'm trying to read the path to connect database from text file *.txt.
In text file is only one line of path to database.
__________________________________________________
In code something like this:

Database = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" PATH FROM *.TXT FILE ";Persist Security Info=False"

Any ideas ?

Image Path From Database
re:
http://www.xtremevbtalk.com/showthread.php?t=256100

I've just read this topic with interest as I'm am on the verge of buidling a new document management system.

It seems the DB method would be more manageable and easier to maintain data integrity albeit at a potential cost to performance and hardware.

The FS method seems to offer better perfomance at a cheaper hardware price. On the offset at least.

You see, the images or documents in my case need to be kept out of the web root for security reasons so that it is the application logic which controls access to the files. This means that when a document is requested, code will load the file into a filestream from its disk location (which most likely for me will be a fileserver across the local network). The code then outputs the stream into the the HTTP output stream. This may negate some of the file system advantages as the process is more similar to the DB retrieval method.

Image Path From Database
I hope i am posting this in the right section.

i am making a small quiz application. The questions and answeres are stored in the database.

the fields in the DB are as follows

Qno
Question
imagepath
option1
option2
option3
option4
Answer

Certain questions have a image associated with them and if a question has a supplementary image the corresponding image button glows and the user can click on it and view the image.

Now in the database for the image path the value is something like this "C:imagesTest.jpg"

Now when the question loads i load the image path to a hidden label lblImgPath

and then for the picture box i give
Picture1.Picture = lblImgPath.caption

But this dos not display the picture. It gives me an error.

How can i get this to work?

Copyright © 2005-08 www.BigResource.com, All rights reserved