According to the docs, ExecuteNonQuery only returns a value other
than -1 on UPDATE, INSERT and DELETE statements. However, your kind
reply stimulated my problem-solving brain cell (I only have one left)
when you wrote " ... returns an integer of records affected."
I "discovered", then used the DataReader.RecordsAffected property.
I'm using the Microsoft.Data.Odbc classes for this exercise, so:
Dim myExecuteQuery as String = "CREATE database IF NOT exists my_database"
myConnection.Open()
Dim myCommand As New OdbcCommand(myExecuteQuery, myConnection)
'Need to use a DataReader before accessing the RecordsAffected property
Dim myDataResults as OdbcDataReader
myDataResults = myCommand.ExecuteReader()
myDataResults.Read()
myDataResults.Close()
'After the DataReader is closed, the RecordsAffected property is set.
DbMessage.Text = myDataResults.RecordsAffected()
If DbMessage.Text = "0"
formMessage.Text = "Database already exists."
Else If DbMessage.Text = "1"
formMessage.Text = "Database created."
End If
MyConnection.Close()