日期:2014-05-16 浏览次数:20886 次
function addUser(strName) '成功返回用户id,否者返回-1 rst.open "tblUser",con,adOpenFowrardOnly,adLockOptimistic,adCmdTable rs.addNew rst("strName")=xxx ; '这里strName为Unique,重复会报错 on error resume next rst.update if err then addUser=-1 else addUser=rst("lngId") end if on error goto 0 end function
cmd.CommandText="INSERT INTO tblUser (lngId,strName) VALUES (?,?)" cmd.parameters.append cmd.createParameter("lngId",adInteger,adParamOutput) cmd.parameters.append cmd.createParameter("strName",adWChar,adParamInput,len(strName),strName) cmd.execute