Page 1 of 1 1
Topic Options
#33331 - 2002-11-23 01:44 AM Update data in MsAccess DB
kjohansen.dk Offline
Lurker

Registered: 2002-11-23
Posts: 3
I have a script today that creates a new entry in a MsAccess Db everytime a user logs on, but now i would like to update the existing entry instead.

It has to check if @USERID exist and if it does update the fields, if it does not do nothing !

Could anyone help me with this.

Thanks

Kenneth Johansen

[ 23. November 2002, 01:52: Message edited by: kjohansen.dk ]

Top
#33332 - 2002-11-23 01:47 AM Re: Update data in MsAccess DB
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
eh?
how may we say much when not know anything about your script?

try sending e-mail to m$ saying that I have a computer with problem, what is the solution [Wink]

plz, give a little more info.

thanks in advance
_________________________
!

download KiXnet

Top
#33333 - 2002-11-23 01:55 AM Re: Update data in MsAccess DB
kjohansen.dk Offline
Lurker

Registered: 2002-11-23
Posts: 3
Why not, that's the kind of questions i get every day... my computer responds in a different way that i'm used to, WHAT is the problem.. you know i can't live with this.. and then when you ask a user of what he has been doing with his pc, he allways replies "nothing"... my reply.. WHY did you turn it on if you didn't use it for anything [Confused]

Sure... sorry how stupid of me.. [Embarrassed]
here it is..

$var1 = @WKSTA
$var2 = @USERID
$var3 = @FULLNAME
$var4 = @LSERVER
$var5 = @CPU
$var6 = @MHZ
$var7 = @IPADDRESS0

$db = "\\dks002\k-drev\edb\inv.mdb"
$cn = CreateObject("adodb.connection")
$cn.connectionstring = "data source=$db; provider=microsoft.jet.oledb.4.0;persist security info=false"
$cn.Open()
$rs = $cn.Execute("insert into inv(UserID,FuldtnavnID,LogonServerID,NetbiosNavnID,OfficeVersionID,StyreSystemID,ServicepackID,IEversionID,IPadrID,Processor_typeID,CPU_hastighedID,NAV_version,RunDate,RunTime) values ('$var2','$var3','$var4','$cname','$fileversion','$Productname','$csdversion','$IEversion','$var7','$var5','$var6','$NAV_VERSION','@date','@time')")
$cn.Close()
$cn = 0

[ 23. November 2002, 02:26: Message edited by: kjohansen.dk ]

Top
#33334 - 2002-11-23 04:07 AM Re: Update data in MsAccess DB
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
This is actually a SQL question and not a KiXtart question in itself.

You should go to the UDF Forum and look up the DB...() UDFs, which is a set of UDFs for database connectivity.

You'd do something like this (pseudo-code):
code:
$userid=dbgetrecordset("SELECT UserID From UserIDTable WHERE USERID='"+@USERID+"'")
if vartype($userid) & 8192
; User ID exists, so update entry
$rc=dbexecutesql("UPDATE UserIDTable SET () VALUES () WHERE USERID='"+@USERID+"'")
else
; user ID does not exist, so insert entry
$rc=dbexecutesql("INSERT INTO UserIDTable...")
endif

Finally, please post your code in between [code] tags. And get rid of those long lines! Read ABC's of KiXtart board etiquette and message to new forum users

[ 23. November 2002, 04:08: Message edited by: sealeopard ]
_________________________
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 978 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.088 seconds in which 0.062 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