The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
Application.GetNewConnection.Execute
Posted: 03 Mar 09 9:54 AM
|
I have a problem with this instructions. INTERNALPRODUCTNO is a field of PRODUCTOROGRAMTABLE
1) n= Application.GetNewConnection.Execute( "SELECT COUNT (*) FROM PRODUCTPROGRAM WHERE INTERNALPRODUCTPROGRAMNO='" &code& "' ") 2) if(n>1) then.....
but send error on instruction 2. What store in n? |
|
|
| |
| |
|
Re: Application.GetNewConnection.Execute
Posted: 04 Mar 09 5:27 AM
|
Set objRS = Application.GetNewConnection.Execute( "SELECT COUNT (*) AS N FROM PRODUCTPROGRAM WHERE INTERNALPRODUCTPROGRAMNO='" &code& "' ") if ( CInt(objRS.Fields("N").Value) > 1 ) then ...
P.S. Google+MSDN will help you |
|
|
|
Re: Application.GetNewConnection.Execute
Posted: 04 Mar 09 5:33 AM
|
recordsets are not a single value - that is what it is complaining about
set n= Application.GetNewConnection.Execute( "SELECT COUNT (*) FROM PRODUCTPROGRAM WHERE INTERNALPRODUCTPROGRAMNO='" &code& "' ")
if(n.fields(0).value >1) then.....
I doesn't clean up after itself though... so memory leakage may occur if you use this a lot better to do something like this:
If FetchSingleValueFromDatabase("SELECT COUNT (*) FROM PRODUCTPROGRAM WHERE INTERNALPRODUCTPROGRAMNO='" &code& "' ") > 1 then
where you have defined a function
Function FetchSingleValueFromDatabase(Query) dim cn, r set cn = application.getnewconnection set r = cn.execute(query) FetchSingleValueFromDatabase = r.fields(0).value set r = nothing set cn = nothing exit function
ws |
|
|
| |
| |
| |
| |
| |
|