dim objconnection
set objconnection= Createobject("Adodb. co nection)
'function to connect sql server
public function opendbconnection()
aqutils. delay 3000
strcoonectionstring="provoder=sqloledb;datasourcee=strdatasourceval;initial catalog=strcatval;security=sspi;persist security info=true"
objconnection. open strcoonectionstring
if objconnection. state=1 then
log. message "DB connect"
else
Log. message "Db not connect"
end if
end function
'function to close db connection
public function closedbconnection()
objconnection. close
if objconnection. state <>1 then
log. message "DB connection close"
else
Log. message "Db not connection not close"
end if
end function
dim strcodedelimiter, strDBrowdelimiter
strdbrowdelimiter="@@"
strcodedelimiter="|"
public function get_db_row()
dim objrecordset, strdbrow
strdbrow=""
if objconnection. state=1 then
set objrecordset =createobject (adodb. recordset")
objrecordset. activeconnection=objconnection
objrecordset. open DBquery, objconnection
if not objrecordset. eof then
while not objrecordset. eof
for intdbcolcounter=0 to objrecordset. fields. count-1 step 1
strcurrentvalue=objrecordset. fields(intdbcolcounter). value
if isnull(strcurrentvalue) or strcurrentvalue ="" then
strcurrentvalue =Null
end if
strdbrow=strdbrow & strcodedelimiter & strcurrentvalue
next
strdbrow= strdbrow & strdbroedelimiter
objrecordset. movenext
wend
if left(strdbrow, 1)=strcodedelimiter then
strdbrow =right(strdbrow, len(strdbrow) - 1)
end if
strdbrow =replace(strdbrow, strdbrowdelimiter & strcodedelimiter, strrowdelimiter)
objrecordset. close
set objrecordset =nothing
else
log. message "no data found"
end if
get_db_row= strdbrow
else
log. message "db connection fail"
end if
end function
'function to update db row
public function uodate_db_row()
dim objrecordset, strdbrow
strdbrow=""
if objconnection. state=1 then
set objrecordset =createobject (adodb. recordset")
objrecordset. activeconnection=objconnection
objrecordset. open DBquery, objconnection
if err. description <>"" then
log. message "no data found in db"
else
bdbflag=true
end if
else
bdbflag=false
log. message "db connection failed"
end if
update_db_row=bdbflag
end function
'function to compare db value
public function comparedbvalue(strvalidatiinval, strdbvalue)
dim bdbvalflag
if aqutils. vartostr (strvalidatiinval) =aqutils. vartostr (strdbvalue) then
bdbvalflag=true
else
bdbvalflag=false
end if
comparedbvalue=bdbvalflag
end function