vb.net - Capturing user who changes database -


i work on few projects front end moved vb.net, back-end's remain in access .accdb format.

with access front end able set data macros captured username of person making changes , record them in audit table, looks little harder .net front-end.

is there way pass information front end database ? or there method of making back-end @ function stored there (it doesn't seem work @ moment)

this code have in back

private declare function apigetusername lib "advapi32.dll" alias _ "getusernamea" (byval lpbuffer string, nsize long) long  public function getusername() string ' returns network login name dim lnglen long, lngx long dim strusername string     strusername = string$(254, 0)     lnglen = 255     lngx = apigetusername(strusername, lnglen)     if lngx <> 0         getusername = left$(strusername, lnglen - 1)     else         getusername = ""     end if end function 

i have public function doing same in front-end, called getusername()

my friend, here we're talking principal differences between working within enclosed environment of ms access, not database application. since inside access native itself, have access internals. moving away model , design should change accordingly. here in, lets call client-server environment, , client knows little besides connection string , server knows nothing client.

this not issue how retrieve user name or other information code. goal design system support auditing. have audit table - good.

depending on security model, either use user name of machine user, or user name of application user. have - in vb easy.

without knowing audit structure, can tell way done, when data changing, create sql transaction using ado.net, , under transaction insert audit data , crud on real data. commit. way, either succeed or fail both - no data modified without audit.

now, step add table (if don't have already) 4 fields:

createdby, creteddate, modifiedby, modifieddate.

each record ready display playing system , when.

and how access db gets user:

  1. via sql contains user column , data "insert ... values('" & user & "', ...."
  2. via separate audit call contains user name
  3. via stored procedure 1 parameter can dedicated pass user info

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

python - No response in ssh.exec_command in paramiko -