Currently, I have 7 separate Xbasic functions that do exactly the same thing except each works with a different fieldname (Photo1, Photo2, Photo3, etc.). I would like to consolidate these into one function and pass in the fieldname as a parameter. The functions are called using an Ajax callback from a button on the UX dialog. I've listed the first 2 functions below as an example so you can understand my question. I would like pass in 'Photo1' and 'Photo2' and replace a <placeholder> as in the final example. I'm sure this is easy so I'm hoping someone can help. Thanks in advance.
function deleteJewelryImage1 as c (e as p)
dim myID as n
myID = e.dataSubmitted.STOCKID
dim sql as c
sql = "update dbo.Inventory set Photo1 = null, Photo1thumb = null where StockID = :myStockID"
dim args as sql::arguments
args.add("myStockID",myID)
dim cn as sql::Connection
cn.open("::Name::jta")
dim flag as l
flag = cn.Execute(sql,args)
cn.close()
end function
function deleteJewelryImage2 as c (e as p)
dim myID as n
myID = e.dataSubmitted.STOCKID
dim sql as c
sql = "update dbo.Inventory set Photo2 = null, Photo2thumb = null where StockID = :myStockID"
dim args as sql::arguments
args.add("myStockID",myID)
dim cn as sql::Connection
cn.open("::Name::jta")
dim flag as l
flag = cn.Execute(sql,args)
cn.close()
end function
function deleteJewelryImage as c (e as p)
dim myID as n
myID = e.dataSubmitted.STOCKID
dim sql as c
sql = "update dbo.Inventory set " + <placeholder> + " = null, " + <placeholder> + "thumb = null where StockID = :myStockID"
dim args as sql::arguments
args.add("myStockID",myID)
dim cn as sql::Connection
cn.open("::Name::jta")
dim flag as l
flag = cn.Execute(sql,args)
cn.close()
end function
function deleteJewelryImage1 as c (e as p)
dim myID as n
myID = e.dataSubmitted.STOCKID
dim sql as c
sql = "update dbo.Inventory set Photo1 = null, Photo1thumb = null where StockID = :myStockID"
dim args as sql::arguments
args.add("myStockID",myID)
dim cn as sql::Connection
cn.open("::Name::jta")
dim flag as l
flag = cn.Execute(sql,args)
cn.close()
end function
function deleteJewelryImage2 as c (e as p)
dim myID as n
myID = e.dataSubmitted.STOCKID
dim sql as c
sql = "update dbo.Inventory set Photo2 = null, Photo2thumb = null where StockID = :myStockID"
dim args as sql::arguments
args.add("myStockID",myID)
dim cn as sql::Connection
cn.open("::Name::jta")
dim flag as l
flag = cn.Execute(sql,args)
cn.close()
end function
function deleteJewelryImage as c (e as p)
dim myID as n
myID = e.dataSubmitted.STOCKID
dim sql as c
sql = "update dbo.Inventory set " + <placeholder> + " = null, " + <placeholder> + "thumb = null where StockID = :myStockID"
dim args as sql::arguments
args.add("myStockID",myID)
dim cn as sql::Connection
cn.open("::Name::jta")
dim flag as l
flag = cn.Execute(sql,args)
cn.close()
end function
Comment