Home >Database >Mysql Tutorial >Why Does My MySQL Query Work in phpMyAdmin but Fail in .NET, and How Can I Fix It?
Users encounter difficulties executing a query in .NET using MySqlAdapter that successfully runs in phpMyAdmin due to the inclusion of @rownum. This system variable is mistaken for a parameter and raises an exception since it's not defined.
To resolve this issue, follow these steps:
using (var sqlConnection = new MySqlConnection(SOURCE_CONNECTION + ";Allow User Variables=True")) { sqlConnection.Open(); MySqlDataAdapter sqlAdapter = new MySqlDataAdapter(SqlStatement, sqlConnection); DataTable table = new DataTable(); sqlAdapter.Fill(table); sqlConnection.Close(); return table; }
For alternative methods of obtaining line numbers, consider the following options:
The above is the detailed content of Why Does My MySQL Query Work in phpMyAdmin but Fail in .NET, and How Can I Fix It?. For more information, please follow other related articles on the PHP Chinese website!