MySqlException: Expected prepared statement marker
Posted by: max m
Date: September 23, 2006 01:09AM

Hi
I am using Mysql5 with .Net connector.

===code:
transacion = mcn.BeginTransaction();
command.Connection = connection;
command.Transaction = mtrans;
command.CommandText = "insert into campaign_main(CampaignName) values(?cname);";
command.Parameters.Add("cname", MySqlDbType.VarChar);
command.Prepare();
command.Parameters["cname"].Value = CampaignName.Text;
command.ExecuteNonQuery();

command.CommandText = "select LAST_INSERT_ID();";
datareader = mcmd.ExecuteReader();
datareader.Read();
int ID = datareader.GetInt32(0);

command.CommandText = "insert into campaign_data(CampaignID,CampaignTypeID,Subject,Body) values(?cid,?ctype,?subject,?body);";
//All the queries works fine till the code reaches this prepare statement.
command.Prepare();
=================
when it reached the last command.prepare statement, the Exception is thrown.

===Full stack trace:
[MySqlException: Expected prepared statement marker]
MySql.Data.MySqlClient.NativeDriver.Prepare(String sql, String[] parmNames) +412
MySql.Data.MySqlClient.MySqlCommand.Prepare() +241
CreateCampaign.SaveTextCampaign() in CreateCampaign.aspx.cs:112
CreateCampaign.FinishButton_Click(Object sender, EventArgs e) in CreateCampaign.aspx.cs:84
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
==========

What am i doing wrong?
Why is the exception thrown only in the second prepare statement, when the both prepare statement does the same thing?

I have also tried replacing ? with @

Options: ReplyQuote


Subject
Written By
Posted
MySqlException: Expected prepared statement marker
September 23, 2006 01:09AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.