WellsCarrie
Well-known member
Ok i have to retrive one at a time a name value from an oracle server database in NJ. I am not allowed (because of network security rules) to set up a join between my oracle server db in AR to the oracle server db in NJ.
so I have set up the following function:
<code>
Public Function GetChainName(ByVal chain As String) As String
Dim strName As String
strCommon = "select chain_name, chain_cd from chain where chain_cd = " & chain
CommonConn.Open()
CommonCmd.Connection = CommonConn
CommonCmd.CommandText = strCommon
Dim reader As OracleClient.OracleDataReader
reader = CommonCmd.ExecuteReader()
While reader.Read()
strName = reader(0)
End While
reader.Close()
CommonConn.Close()
Return strName
End Function
</code>
I have used functions like this in several applications and never had a problem. However now when I call the funciton the first time it returns "Nothing" as the strName. On all consecutive calls though it returns the contents of the chain_name field as expected.
I have walked through the function with debug and reader.read() is true, but on the first time called it never enters the while statement. On all consecutive calls however it does. Since I am using the KEY field of chain_cd in the select, the query will only ever return ONE record. And yes I have checked that the first value sent to the function is a vlaid row in chain.
Any one have any ideas what I've done wrong or what I could just plain do diffrently?
Thanks!
so I have set up the following function:
<code>
Public Function GetChainName(ByVal chain As String) As String
Dim strName As String
strCommon = "select chain_name, chain_cd from chain where chain_cd = " & chain
CommonConn.Open()
CommonCmd.Connection = CommonConn
CommonCmd.CommandText = strCommon
Dim reader As OracleClient.OracleDataReader
reader = CommonCmd.ExecuteReader()
While reader.Read()
strName = reader(0)
End While
reader.Close()
CommonConn.Close()
Return strName
End Function
</code>
I have used functions like this in several applications and never had a problem. However now when I call the funciton the first time it returns "Nothing" as the strName. On all consecutive calls though it returns the contents of the chain_name field as expected.
I have walked through the function with debug and reader.read() is true, but on the first time called it never enters the while statement. On all consecutive calls however it does. Since I am using the KEY field of chain_cd in the select, the query will only ever return ONE record. And yes I have checked that the first value sent to the function is a vlaid row in chain.
Any one have any ideas what I've done wrong or what I could just plain do diffrently?
Thanks!
Last edited: