473,830 Members | 2,241 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Modifying database schema from a vb program

This is sort of a newbie question.

I have an access database application. It is split into a backend data
file and GUI. I need to make changes to the db schema. The production
version of the data file is not accessible to me remotely. Rather than
make changes at the client location the best idea seems to be to write
a program to do this programaticaly. Just a small exe that the client
can download and run which will make the modifications. IS this the
best way to go? Can it be done easily in VB?

Aug 11 '06 #1
6 2298

"Welie" <we******@gmail .comschreef in bericht news:11******** *************@b 28g2000cwb.goog legroups.com...
This is sort of a newbie question.

I have an access database application. It is split into a backend data
file and GUI. I need to make changes to the db schema. The production
version of the data file is not accessible to me remotely. Rather than
make changes at the client location the best idea seems to be to write
a program to do this programaticaly. Just a small exe that the client
can download and run which will make the modifications. IS this the
best way to go? Can it be done easily in VB?
Can definitively be done, but IMO this is not newbie stuff.

Why would you send a separate exe if you can do the same from your frontend?
Send them a new frontend which contains update-code.
In your update-code check if the update is still needed. (Check version of backend)
But as I told you: this is not newbie stuff.

Arno R

Aug 11 '06 #2
Yes, I do this all the time....

In fact, when I send clients a new front end (actually, they update it via
the following process).

http://www.kallal.ca/ridestutorialp/upgrade.html

Anyway, all the above does is un-packs (un-zips) a new front end
to the users machine. When the user launches the new front end, it
first re-links using the clients path name to the back end..

Next, my start-up code then runs updates to tables etc.

There is typical several operations that are quite common

1) - adding a new field to a existing table
2) - increasing the length of a existing fields
3) - adding a whole new table to the back end...
#1 is quite easy. Here is what my code will look like:

' add default fields

' check table defaults..and add default Tour Type field...

Set rst = CurrentDb.OpenR ecordset("tblDe faults")
On Error GoTo AddDefaultTourT ype
Temp = rst!DefaultTour Type.Name

rst.Close
Set rst = Nothing
Exit Sub
AddDefaultTourT ype:

rst.Close
GoSub AddDefaultTourT ypes

Resume Next

AddDefaultTourT ypes:

strToDB = strBackEnd

Set db = OpenDatabase(st rToDB)

Set nT = db.TableDefs("t blDefaults")
nT.Fields.Appen d nT.CreateField( "DefaultTourTyp e", dbLong)
nT.Fields.Refre sh
db.Close
Set db = Nothing

Set rst = CurrentDb.OpenR ecordset("tblDe faults")
Return
End Sub

So, the above gives you an idea.....

So, my upgrade code actually runs every time on startup. This ensures that
if they client grabs a older data file (say from a backup), version, then
the upgrade code always runs...

Here is an example to upgrade the size of a field

' check size of Anotes in tblGroupRemind

Set db = CurrentDb
Set dbTable = db.TableDefs("t blGroupRemind")
Dim intSize As Integer
intSize = dbTable("ANotes ").Size

Set dbTable = Nothing

If intSize = 50 Then

Dim nField As DAO.Field

Set db = OpenDatabase(st rBackEnd)

db.Execute "ALTER TABLE tblGroupRemind ALTER COLUMN Anotes text(255)",
dbFailOnError

End If

db.Close

Now, to add a new table, I actually simply include the table in the front
end, but with a "C" appended to the end.
I also have the link already made in the front end...so, I do NOT have to
add this link via code...since it already
exist!! So, adding a whole new table to the back end is not hard if you take
this approach....

strFromDB = CurrentProject. FullName
strToDB = strBackEnd

DoCmd.TransferD atabase acExport, "Microsoft Access", strToDB, acTable,
"tblRemindDefau ltsC", "tblRemindDefau lts", False

Set db = CurrentDb
strLink = ";DATABASE= " & strBackEnd
Set dbTable = db.TableDefs("t blRemindDefault s")
dbTable.Connect = strLink
dbTable.Refresh Link

In fact, you can see it is only 3 lines of code to add the whole table to
the back end (since I just copy it from the front end). By the way, that
table is never deleted in the front end..but, just stays there.....you never
know when the client might open a older data file....

the next few lines are needed, since the re-link code in start-up would have
FAILED for the links in the front end..since NO table in the back end
existed...So, after you add the table, you must re-fresh the table link.
However, since the table link IS PROVIDED in my new front end...at least I
don't have to write code. So, having a table, and the link already done in
the front end saves a LOT of coding to create a new table....
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl************* ****@msn.com
Aug 11 '06 #3
Albert D. Kallal wrote:
Yes, I do this all the time....
SNIP
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl************* ****@msn.com
Albert, thank you so much for that detailed response. It's like a mini
tutorial and a quick read looks like it teaches me much of what I need
to know. A very good educational piece! Later today I'll start coding.

I guess it's not a newbie question. I should give myself more credit,
though I still feel very new to Access/DAO api.

-EW

Aug 13 '06 #4

Albert D. Kallal wrote:
Set db = CurrentDb
strLink = ";DATABASE= " & strBackEnd
Set dbTable = db.TableDefs("t blRemindDefault s")
dbTable.Connect = strLink
dbTable.Refresh Link

I have been following Alberts example above. The assumption is that the
linked table exists in the current database, but the link needs to be
refreshed since the underlying table may not have existed in the back
end database. In the code previous to this, I created the table in the
back end. I get to the point of setting the Connect property
(dbTable.Connec t = strLink) but I get an error that the object no
longer exists or is invalid.

There is actually one thing that I am doing different than the above
code (but I am fairly certain I made the change only b/c I was having
this problem and was attempting a work around). The change is:

Set dbTable = CurrentDb.Table Defs("tblRemind Defaults")
Any ideas why this would be happening?

Finally though, it seems that even without reliniking the table, the
link works anyhow, even thought the table did not exists when the db
started up.

Thanks,
Elie

Aug 21 '06 #5
On 21 Aug 2006 03:18:26 -0700, "Welie" <we******@gmail .comwrote:

If the table is new in the BE, add a line:
dbTable.Tablede fs.Refresh
before you try to link to it.

-Tom.

>
Albert D. Kallal wrote:
> Set db = CurrentDb
strLink = ";DATABASE= " & strBackEnd
Set dbTable = db.TableDefs("t blRemindDefault s")
dbTable.Connect = strLink
dbTable.Refresh Link


I have been following Alberts example above. The assumption is that the
linked table exists in the current database, but the link needs to be
refreshed since the underlying table may not have existed in the back
end database. In the code previous to this, I created the table in the
back end. I get to the point of setting the Connect property
(dbTable.Conne ct = strLink) but I get an error that the object no
longer exists or is invalid.

There is actually one thing that I am doing different than the above
code (but I am fairly certain I made the change only b/c I was having
this problem and was attempting a work around). The change is:

Set dbTable = CurrentDb.Table Defs("tblRemind Defaults")
Any ideas why this would be happening?

Finally though, it seems that even without reliniking the table, the
link works anyhow, even thought the table did not exists when the db
started up.

Thanks,
Elie
Aug 21 '06 #6

Albert D. Kallal wrote:
Yes, I do this all the time....

In fact, when I send clients a new front end (actually, they update it via
the following process).

Set db = CurrentDb
strLink = ";DATABASE= " & strBackEnd
Set dbTable = db.TableDefs("t blRemindDefault s")
dbTable.Connect = strLink
dbTable.Refresh Link

Albert,

After I do the set db = currentDB, I can no longer make changes to vba
code modules. I get an error that "you do not have exclusive access to
the database at this time".

I have seen many postings about this but nothing that solves my
problems. Please Help!

Aug 21 '06 #7

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

Similar topics

6
6887
by: Dim St Thomas | last post by:
I am a developer working on a database client program. I am testing this program on a Windows XP machine (1.5 GHz AMD chip, 480 Mb RAM, 60 Gb disk) This machine has Oracle 9.2.0.1.0 and RedBrick database software installed. I am testing the software by creating small test databases. If I create an Oracle database using the Database Configuration Assistant, it takes forever just to create the database. If I choose to create a new database...
4
3278
by: Heejeong Lee | last post by:
I am going to begin following project Description of the project: One of the proposed ways of storing XML is to "shred" the structure of the XML document and insert it into a relational DBMS. To do this, I will consider the query workload over the XML document. The purpose of this project is to
0
2411
by: Mike | last post by:
Hello, I'm trying to understand how to map hierarchical XML data to relational database tables, but I seem to be missing something. I'm not a database expert, but I know the basics. XML seems so much more intuitive to me, though. Anyway, let me make up an example: Say we have an address book, in XML format, that is to be uploaded by a customer and then mapped into relational database tables. I would start by creating an XML Schema...
7
3544
by: Együd Csaba | last post by:
Hi, I've a problem with some of my stored procs. My config is: RH7.1, Postgres 7.3.2 I had converted a few fields of a few tables from one type to another and after this I made all the necessary changes on the functions and recreated all my types and functions. It seemd to be all right, but the newly created functions won't work anymore.
2
28610
by: Kums | last post by:
What is the maximum permissible size of a database? Is there any limitation. What is the maximum # of tablespace's allowed in a database? Thanks for your response.
0
5831
by: M. David Johnson | last post by:
I cannot get my OleDbDataAdapter to update my database table from my local dataset table. The Knowledge Base doesn't seem to help - see item 10 below. I have a Microsoft Access 2000 database which indexes computer magazine articles for personal reference. I am developing a Visual Basic.NET program whose sole purpose is to enter new records into the database. No updates to existing entries, no deletions, and no display
29
3589
by: MP | last post by:
Greets, context: vb6/ado/.mdb/jet 4.0 (no access)/sql beginning learner, first database, planning stages (I think the underlying question here is whether to normalize or not to normalize this one data field - but i'm not sure) :-) Background info:
10
4306
by: shsandeep | last post by:
The ETL application loaded around 3000 rows in 14 seconds in a Development database while it took 2 hours to load in a UAT database. UAT db is partitioned. Dev db is not partitioned. the application looks for existing rows in the table...if they already exist then it updates otherwise inserts them. The table is pretty large, around 6.5 million rows.
1
1396
by: tobycraftse | last post by:
Am now using SQLXML to load XML file into a SQLServer database. Here is how it works - XML(Data) + XSD(Schema) --> through MS SQLXML COM program (EXE) --> SQLServer2005
0
9793
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
9642
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10774
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
10489
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
10202
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9314
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
6950
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
5617
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
3076
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.