ASP C# から呼び出すと、クエリは値を返しませんが、MySQL サーバーに接続して同じクエリを入力すると、正しい値が返されます。問題を発見できませんでした。
コード セグメントは次のとおりです。
try
{
personquery = "select b.* from booking b, makes m "+
"where m.personid="+
DataDeneme1.login.personid.ToString() +
"and m.bookingno=b.bookingno";
con = new MySqlConnection(System.Configuration.ConfigurationManager.AppSettings.Get("connectionString"));
cmd.CommandText = personquery;
con.Open();
cmd.Connection = con;
adap = new MySqlDataAdapter(personquery, con);
adap.Fill(ds);
// CheckBoxList1.DataSource = ds;
// CheckBoxList1.DataBind();
GridView1.DataSource = ds;
GridView1.DataBind();
con.Close();
}
catch (Exception ex)
{
Response.Write(ex.Message);
Response.Write(ex.StackTrace);
}
mysql サーバーからの入力と出力:
mysql> select b.* from booking b, makes m where m.personid=1 and m.bookingno=b.bookingno;
+-----------+-----------------+--------------+-------------+------------+-------------+
| bookingno | reservationdate | dropoffplace | pickupplace | pickupdate | dropoffdate |
+-----------+-----------------+--------------+-------------+------------+-------------+
| 8 | 2011-05-09 | Ankara | Ankara | 2011-05-10 | 2011-05-15 |
| 9 | 2011-05-09 | Ankara | Ankara | 2011-05-20 | 2011-05-25 |
+-----------+-----------------+--------------+-------------+------------+-------------+
2 rows in set (0.00 sec)
そして例外メッセージ....
SQL 構文にエラーがあります。MySql.Data.MySqlClient.MySqlStream.ReadPacket() の MySql.Data.MySqlClient.NativeDriver. MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId、Int32&ectedRows、Int32&insertId) での GetResult(Int32& affectedRow、Int32& insertId) .NextResult() での MySql.Data.MySqlClient.MySqlCommand.ExecuteReader (CommandBehavior 動作) での MySql.Data.MySqlClient.MySqlCommand.ExecuteDbDataReader(CommandBehavior 動作) での System.Data.Common.DbCommand.System.Data.IDbCommand.