我有一个类似于下面的函数,它使用传入的 SQL 字符串更新我的数据库。
多年来一直使用它,一切都很好,但它只是发生在我身上。在 phpMyAdmin 中执行删除/更新命令时,是否可以从数据库接收到“删除/更新的行数”之类的响应?
Imports MySql.Data.MySqlClient
Function doUpdate(sql)
Dim DBConnection = ConfigurationManager.ConnectionStrings("dbConn").ConnectionString
'this is getting the connection string from web.config file.
Dim connection As MySqlConnection = MySqlConnection(DBConnection)
Dim dataUpdate As MySqlCommand = MySqlCommand(sql, connection)
Using connection
connection.Open()
Try
dataUpdate.ExecuteNonQuery()
Catch ex As Exception
HttpContext.Current.Response.Write(ex.ToString() & "<hr/>" & InsertSql)
End Try
End Using
' // I WANT TO RETRIEVE A RESPONSE HERE
Return DatabaseResponse
end function