What is wrong in the following code? I am trying to retrieve data from the datbase, and this error is shows. kindly provide a solution. Error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'wrap' at line 1 Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Line 19: da.SelectCommand = cmd;
Line 20: DataSet ds = new DataSet();
Line 21: da.Fill(ds,"Recipe_Info");
Line 22: DataRow dr = ds.Tables["Recipe_Info"].Rows[0];
Line 23: String r_name, r_ing, r_desc, r_ins;
Exception Details: MySql.Data.MySqlClient.MySqlException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'wrap' at line 1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using MySql.Data.MySqlClient;
public partial class Detailed_Recipe_View : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
String recipe_name=Session["Recipe_Name"].ToString();
MySqlConnection con = new MySqlConnection("Server=localhost;Database=FreedomKitchen;Uid=root;Password=;");
con.Open();
MySqlCommand cmd = new MySqlCommand("select User_ID,Recipe_Name,All_Ingredients,Recipe_Description,Recipe_Instructions from Recipes where Recipe_Name="+recipe_name, con);
MySqlDataAdapter da = new MySqlDataAdapter();
da.SelectCommand = cmd;
DataSet ds = new DataSet();
da.Fill(ds,"Recipe_Info");
DataRow dr = ds.Tables["Recipe_Info"].Rows[0];
String r_name, r_ing, r_desc, r_ins;
r_name = Convert.ToString(dr["Recipe_Name"]);
r_ing = Convert.ToString(dr["All_Ingredients"]);
r_desc = Convert.ToString(dr["Recipe_Description"]);
r_ins = Convert.ToString(dr["Recipe_Instructions"]);
txtRecipeName.Text = r_name;
txtDescription.Text = r_desc;
txtAllIngredients.Text = r_ing;
txtInstructions.Text = r_ins;
}
}