Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Resolving warning
Message
From
26/12/2021 23:33:48
 
 
To
All
General information
Forum:
VB.NET
Category:
Coding, syntax and commands
Title:
Resolving warning
Miscellaneous
Thread ID:
01683083
Message ID:
01683083
Views:
59
With Visual Studio 2022, this code gives a warning :
' Execute a SQL script
	' expC1 Script
	' expL1 Execute with results
	Public Function ExecuteSQLScript(ByVal tcScript As String,
	 Optional ByVal tlExecuteWithResult As Boolean = False) As Boolean
		Dim lcConnectionString As String = ""
		Dim lcScript As String = ""
		Dim llSuccess As Boolean = False
		Dim lnDateNow As Double = 0
		Dim lnDateNow2 As Double = 0
		Dim lnElapse As Double = 0
		Dim loServer As Server = Nothing
		Dim loServerConnection As ServerConnection = Nothing
		Dim loSQLConnection As SqlConnection = Nothing

		' Reset the values
		cScriptMessage = ""
		nDuration = 0

		' Start time
		lnDateNow = Date.Now.Ticks

		' Initialize the data object
		If Not InitializeDataObject("") Then
			Return False
		End If

		Try

			' Get the proper definition as per the current scope
			If oProcess Is Nothing Then
				lcConnectionString = oApp.aConnection(nConnectionString, 1)
			Else
				lcConnectionString = oProcess.aConnection(nConnectionString, 1)
			End If

			' Initialize the SMO object
			loSQLConnection = New SqlConnection(lcConnectionString)
			loServerConnection = New ServerConnection(loSQLConnection)
The last line gives this message :
Runtime errors might occur when converting 'SqlConnection' to 'IRenewableToken'.

ServerConnection comes from namespace System.Data.SqlClient. The Imports declaration is properly defined on top of the file. I have seen a suggestion to change the namespace to be Microsoft. Data.SqlClient. But, doing that breaks everything in the class.

Anyone would have an idea on how to fix this?

It would be nice to get rid of that warning.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Reply
Map
View

Click here to load this message in the networking platform