473,698 Members | 2,302 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Change Database FileName And Copy Into Existing Folder


Using vb.net

Hello. Here is the problem that I am having. I have a program which
makes a copy of my working database (wasa.mdb) and saves it to another
folder (/bin/backup/) with the filename (9-27-2005,1210PM.mdb ) *Note
This Is The Current System Date And Time Of The Save.*

I would like to have the function where when the user selects The
"Restore Database" button (btnRestore) that it will use an Open File
Dialog box and let them select which version of the database they would
like to use for the restore. Then I need the functionallity where once
the database version is selected, it will rename the
(9-27-2005,1210PM.mdb ) to (wasa.mdb) so that my application can use the
database. It can overwrite the current file as I will throw the
functionallity to save the database before the restore. Can anyone help?

Nov 21 '05 #1
5 1662
I forgot to add this although some might realize it. I need the renamed
file (wasa.mdb) to be inserted back into the /bin/ folder where my
application is run. Thanks !

Nov 21 '05 #2
Hi,

Take a look at File.Copy method, e.g.:

~
File.Copy(OpenF ileDialog1.File Name,
Path.Combine(Ap plication.Start upPath, "wasa.mdb") , True) REM Untested
~

HTH,
Roman

"Webbyz" <ma*******@gmai l.com> ???????/???????? ? ???????? ?????????:
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
I forgot to add this although some might realize it. I need the renamed file (wasa.mdb) to be inserted back into the /bin/ folder where my
application is run. Thanks !

Nov 21 '05 #3
I used the code and I imported System.IO and here is the error I got..

An unhandled exception of type 'System.Argumen tException' occurred in
mscorlib.dll

Additional information: Empty file name is not legal.

What's up with that?

Nov 21 '05 #4
Have you already shown your OpenFileDialog?

Sample:

~
Dim ofp As New OpenFileDialog
ofp.Filter = "Access Databases (*.mdb)|*.mdb"
If ofp.ShowDialog( Me) = DialogResult.OK Then
File.Copy(ofp.F ileName,
Path.Combine(Ap plication.Start upPath, "wasa.mdb") , True)
MessageBox.Show ("You restored a backup: " &
Path.GetFileNam e(ofp.FileName) )
Else
MessageBox.Show ("User doesn't want to restore a backup!")
End If
~

Roman

"Webbyz" <ma*******@gmai l.com> ???????/???????? ? ???????? ?????????:
news:11******** *************@g 49g2000cwa.goog legroups.com...
I used the code and I imported System.IO and here is the error I got..

An unhandled exception of type 'System.Argumen tException' occurred in
mscorlib.dll

Additional information: Empty file name is not legal.

What's up with that?

Nov 21 '05 #5
Dragon You Rock! Works like a charm. Thanks a bunch!

Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
22936
by: jimserac | last post by:
I had previously posted this in an Access forum with negative results so will try here. Although this question specifies an Access database, I also wish to accomplish this with a large MS SQL Server database that we have. Question follows: The following SQL statement, used in VBScript,
2
11089
by: joshsackett | last post by:
Hi all, Is it possible to move the distribution database to a new folder/drive without removing replication? I am attempting to do it the same way you would move tempdb: ALTER DATABASE distribution MODIFY FILE (name = distmodel, filename = 'C:\DISTMOVED\distribution.MDF') ALTER DATABASE distribution MODIFY FILE (name = distmodel_log, filename = 'C:\DISTMOVED\distribution.LDF')
4
2833
by: Peter Larsson | last post by:
Hello everybody, I'm developing a system for a company that has production at two different locations. The production is stored in an Access database at each location, and I need to find a way to fetch data from both these databases and present them to the boss (who is at one of the locations). I've built a report generator in Excel (using VBA) that fetches data via ODBC from the database that's located in the same building. However, I...
11
12685
by: dixie | last post by:
If I wanted to be able to copy all of the tables in an existing database called Original.mde to another database called New.mde from a button click event in Original.mde, is there an easy way of coding it without naming every single table in Original.mde. I am looking for a way of updating a database on site without needing to access the database window and import the existing tables into a new empty database. dixie
4
5152
by: Brian K. | last post by:
I am trying to split up and secure a database that we've been using on a network for a few years, following the procedure listed in Q304932 from microsoft. I create a new blank database for the front end, and am able to import tables and link from the backend. Queries come in ok too. When I tried to import Modules, forms, and reports, most of them failed with the error: "File Not Found:...
2
1262
by: Marc | last post by:
Hi, I hope to find some information on this way, I used to develop databases in Access and want to try visual basic VB.net 2005 Could someone help me how to link 2 datagrid like in the first grid I want to show Customers and the second grid Customers Contacts from Customers. I also have another question,
6
3866
by: Bob Alston | last post by:
I am looking for others who have built systems to scan documents, index them and then make them accessible from an Access database. My environment is a nonprofit with about 20-25 case workers who use laptops. They have Access databases on their laptops and the data is replicated. The idea is that each case worker would scan their own documents, either remotely or back at the office. And NO I am not planning to store the scanned...
12
11887
by: JHNielson | last post by:
I have an Access database I am importing records into from an Excel file. I currently have set it up by creating a linked table to the Excel sheet. But I am not sure that is the best way to do what I'm trying to achieve. So, I have two questions: 1) The user will be copying all the Excel files into one folder (this is just how I currently envision it). Is there a way to copy records from all those files in the folder, without having to...
2
1656
by: JHNielson | last post by:
I posted this in the Access forum, but I think the answer may be a VBA script, so I thought I would also post this here... I have an Access database I am importing records into from an Excel file. I currently have set it up by creating a linked table to the Excel sheet. But I am not sure that is the best way to do what I'm trying to achieve. So, I have two questions: 1) The user will be copying all the Excel files into one folder (this...
0
8674
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9028
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7728
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2330
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.