I have a string connection in my script to an ODBC connection. I want to multiply two fields in my connection string to return results. One of the fields is a text (char) field and I need to convert this to complete the calculation.
I have tested my syntax in SQL but I cannot get the vbScript to run. It gives the common elexical element not found. Here is the connection string.
'strSQL = "SELECT Sum(CASE when CI_Item.ShipWeight = ' ' then 0" & _ '"when CI_Item.ShipWeight > 0 Then (Cast(CI_Item.ShipWeight as Numeric)*(SO_SalesOrderDetail.QuantityOrdered))+0 " & _ '"when CI_Item.ShipWeight < 0 Then (Cast(CI_Item.ShipWeight as Numeric)*(SO_SalesOrderDetail.QuantityOrdered))+0 " & _ '"when CI_Item.ShipWeight = 0 Then 0 " & _ '"when CI_Item.ShipWeight = Null Then 0 " & _ '"Else 0 End) as TotalQuantity FROM SO_SalesOrderDetail, CI_Item " & _ "where SO_SalesOrderDetail.ItemCode = CI_Item.ItemCode " & _ '" and (((SO_SalesOrderDetail.SalesOrderNo)='"+ SO_SalesOrder_bus_SalesOrderNo +"'))"
(1) what you showed isn't a connection string, but an SQL statement; if this is just a kind of typo and you can connect to your DB and execute simple statements ignore (1); otherwise post more of your code
(2) if your
'strSQL = "SELECT S...
(mark the ') isn't a copy & paste artefact, remove the ' and try again
(3) if (2) helps, double check your statement, e.g.
Here is all my my code. I reviewed for spaces, etc and still get a element not found message. I have set a value for a string variable called strCASE which is inserted into the strSQL statement. This is set inside a much larger script that declares and passes other values like SO_SalesOrder_bus_SalesOrderNo.
I created a message box when I run my script to look at the strCASE and strSQL once they are put together. It all looks good. So I'm wondering if I'm failing on the CAST language or using the CASE statement.