0

I have two very similar vb.net projects. Both have recently been converted from .net 1.1 to 3.5.

In one, the following code gives no warnings. In the other I get a warning when I try to set the parameters of the mysql command object:

 Public Sub mySub(ByVal applid As Integer, ByVal text1 As String,ByVal text2 As String)
            Dim objMYSQL As New Classes.DataAccess.clsMysql
            Dim objConnection As New MySQL.Data.MySQLClient.MySqlConnection
            objConnection = objMYSQL.ConnectionNew("myDB")
            Dim objCommand As MySqlCommand

            Dim InsertSQL As String = ""

            InsertSQL = "insert into [myTable] ([text1],[text1])"
            InsertSQL = InsertSQL + " values(@txt1,@txt2)"

            objCommand = New MySQL.Data.MySQLClient.MySqlCommand(InsertSQL, objConnection)
            objCommand.CommandType = CommandType.Text

           'Set parameters
            objCommand.Parameters.Add("@txt1", text1) ' Warning here...
            objCommand.Parameters.Add("@txt2", text2) '...and here!

            objCommand.ExecuteNonQuery()

        End Sub

Here's the warning:

Public Function Add(parameterName As String, value As Object) As MySql.Data.MySqlClient.MySqlParameter' is obsolete: 'Add(String parameterName, Object value) has been deprecated. Use AddWithValue(String parameterName, Object value)'

If I follow the instructions, and use "AddWithValue" instead, the warnings go. But I can't figure out why I don't get these messages in the first project.

It seems there is something different in their configuration, but I can't figure out what. Both use the same version of mysql.data.dll. And both are configured to show warnings in the same circumstances via the project>properties>compile menu. Can anyone suggest where else to check?

Urbycoz
  • 7,247
  • 20
  • 70
  • 108

1 Answers1

2

It might have been disabled using /nowarn.

It might be worth closing down the project and opening the .vbproj file in a text editor and searching for NoWarn since I think it might also be somewhere else in there.

Hans Olsson
  • 54,199
  • 15
  • 94
  • 116