Page 1 of 1 1
Topic Options
#32934 - 2002-11-20 01:04 AM An array into a record
rockdog Offline
Lurker

Registered: 2002-11-09
Posts: 2
I'm new to this so my terminology may be a little off but here we go. I want to take the software inventory ("items") that I create using "Function GetUninstallInfo()" (which works great BTW) and import into my Access Database. The problem I'm looking at is that every workstation is not going to have the same amount of programs on them. I just don't get the logic of connecting the "items" of the array to the fields in my access database. I have an okay understanding of how to make the links but not how to tell the script to input data into fields of a record and/or create fields if there are not enough in the table already. Any help/idea's would be greatly appreciated! Thanks.
Top
#32935 - 2002-11-20 01:09 AM Re: An array into a record
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Database 101

Normalize your data.

You should not create more fields. Your approach should be to create a stable structure such as:

ComputerName Text(15)
Application Text(100)

Then using a loop:
code:
for each $app in $AppARRAY
insert into Table $computer, $app
next



[ 20. November 2002, 01:10: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#32936 - 2002-11-20 01:11 AM Re: An array into a record
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
created similar thing some time ago but with no real db (collection in registry [Eek!] )

first thing to ask then should be, do you know, how to add fields into the db at all?
_________________________
!

download KiXnet

Top
#32937 - 2002-11-20 04:05 PM Re: An array into a record
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You'll need at leats two database tables. Table 1 with anme tblComputer has Computer ID and ComputerName. Table 2 with name tblSoftware has SoftwareID and SoftwareName
Then you do SQL like this:
code:
SELECT ComputerID FROM tblComputer WHERE ComputerName=@WKSTA
INSERT INTO tblSoftware (SoftwareName) Values (SoftwareName)

You'll need to do this for every piece of software and also check beforehand if the entry is already present for the specific computer.

Us the DB...() UDFs in the UDF Forum, they do database stuff, and you'll have to use KiXtart 4.12

[ 20. November 2002, 16:06: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#32938 - 2002-11-20 04:38 PM Re: An array into a record
Waltz Offline
Seasoned Scripter

Registered: 2002-08-01
Posts: 485
Loc: Waterloo, Ontario, Canada
...and you might want to consider a 3rd table,
tblSoftwareDetails with fldComputerID and fldSoftwareID, to 'join' the other 2 tables...
_________________________
We all live in a Yellow Subroutine...

Top
#32939 - 2002-11-20 04:41 PM Re: An array into a record
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
That is true. You would want to normalize the tables. It might be sufficient to insert the ComputerId togehter with the software name in the software table, though. I just whipped it up quickly to provide the basic SQL concept, not to fully design the database.
_________________________
There are two types of vessels, submarines and targets.

Top
#32940 - 2002-11-20 04:48 PM Re: An array into a record
Waltz Offline
Seasoned Scripter

Registered: 2002-08-01
Posts: 485
Loc: Waterloo, Ontario, Canada
Understood...
I just whipped in the 3rd table as a suggestion; if he's got time to fix it later, he should find time to try to do it 'better' at the outset... [Wink]
_________________________
We all live in a Yellow Subroutine...

Top
#32941 - 2002-11-20 05:30 PM Re: An array into a record
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Yeah, I would actually make the software table bigger containing Company Name, Product Name, and Product Version in separate fields. However, the tables would be linked through a third look-up table, htus properly normalizing the database.
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1574 anonymous users online.
Newest Members
BeeEm, min_seow, Audio, Hoschi, Comet
17882 Registered Users

Generated in 0.069 seconds in which 0.037 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org