INSERT

dim cn as sql::Connection

dim args as sql::Arguments

cn.open("::name::conn")


vsql = <<%txt%

INSERT INTO mytable

firstname,lastname)

VALUES

(:firstname,:lastname)

%txt%


args.set("lastname","wood")

args.set("firstname","steve")


cn.execute(vsql,args)

cn.close()


Insert Examples

Example 1 - insert in to a Login Log


dim cn as sql::Connection

cn.open("::name::conn")

vsql = <<%txt%

INSERT INTO wt_website_login

(

event_time,

ip,

userid,

pwd_expires,

login_expires,

login_error,

logout

VALUES

(

:event_time,

:ip,

:userid,

:pwd_expires,

:login_expires,

:login_error,

:logout

)

%txt%

args.add("event_time",time("MM-dd-yyyy 0h:0m:0s"))

args.add("ip",e.IP)

args.add("userid",e.userid)

args.add("pwd_expires",e.passexp)

args.add("login_expires",e.loginexp)

args.add("login_error",e.loginerror)

args.add("logout",e.logout)

if cn.execute(vsql,args)=.f.

       errorout("LOGIN_LOG|"+cn.callresult.text)

end if

cn.FreeResult()

cn.close()