Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have SQL Function this function retrieve true Or false how i can use this sql function by vb.net to use this value

What I have tried:

I have SQL Function this function retrieve true Or false how i can use this sql function by vb.net to use this value
Posted
Updated 30-Nov-17 0:53am
v2

1 solution

Try:
Using con As New SqlConnection(strConnect)
	con.Open()
	Using com As New SqlCommand("SELECT dbo.MyFunctionName()", con)
		Using reader As SqlDataReader = com.ExecuteReader()
			While reader.Read()
				Dim i As Integer = CInt(reader(0))
                                Dim b As Boolean = i = 0
				...
			End While
		End Using
	End Using
End Using
 
Share this answer
 
Comments
Jörgen Andersson 28-Nov-17 4:47am    
I thought you didn't touch VB.Net. :-)
It was almost flawless, but alas, this construct won't work: Dim b As Boolean = i = 0
I'd recommend: Dim b As Boolean = IF(i = 0,True,False)
OriginalGriff 28-Nov-17 5:01am    
Are you sure?
    Sub Main()
        Dim i As Integer = 0
        For i = 0 To 2
            Dim b As Boolean = i = 0
            Console.WriteLine(b)
        Next
        Console.ReadLine()
    End Sub

Results:
True
False
False
Jörgen Andersson 28-Nov-17 6:58am    
I'm stumped!
It's one of these things I've "known" since forever. I'll have to check if I've always been wrong or if they have changed it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900