Hi
Sir,
I want to developed vote polling application in c# .
with mysql database .but it give error like ADO: Column 'Answer' does not belong to table Table .
plz help me.
code are as follows,
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Data.Odbc;
partial class Poll: System.Web.UI.Page
{
protected void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
lblPollQuestion.Text = "Answer";
DisplayPoll();
}
}
private void DisplayPoll()
{
try
{
DataSet ds = GetActivePoll();
lblPollQuestion.Text = (ds.Tables[0].Rows[0]["Question"]).ToString();
int i = 0;
foreach (DataRow dr in ds.Tables[0].Rows)
{
rdoPollOptionList.Items.Add(dr["Answer"].ToString());
rdoPollOptionList.Items[i].Value = dr["PK_OptionId"].ToString();
rdoPollOptionList.SelectedIndex =0;
i++;
}
} catch (Exception ex)
{
throw ex;
}
}
private DataSet GetActivePoll()
{
try
{
string strConnString = (System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"]).ToString();
OdbcConnection MyConnection = new OdbcConnection(strConnString );
MyConnection.Open();
OdbcCommand sqlCmd = new OdbcCommand();
sqlCmd.CommandText = "{call GetActivePoll}";
sqlCmd.CommandType = System.Data.CommandType.StoredProcedure;
sqlCmd.Connection = MyConnection ;
DataSet ds = new DataSet();
OdbcDataAdapter da = new OdbcDataAdapter(sqlCmd);
da.Fill(ds);
MyConnection.Close();
return ds;
} catch (Exception ex)
{
throw ex;
}
}
protected void btnVote_Click( object sender , System.EventArgs e)
{
if (Response.Cookies["Voted"]!= null)
{
Response.Cookies["Voted"].Value = "Voted";
Response.Cookies["Voted"].Expires = DateTime.Now.AddDays(1);
lblError.Visible = false;
RecordVote();
} else
{
lblError.Visible = true;
}
}
private void RecordVote()
{
string strConnString= System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
OdbcConnection MyConnection = new OdbcConnection(strConnString );
MyConnection.Open();
OdbcCommand sqlCmd = new OdbcCommand();
sqlCmd.CommandText = "{call IncreamentVotes(?)}";
sqlCmd.CommandType = System.Data.CommandType.StoredProcedure;
sqlCmd.Connection = MyConnection;
OdbcParameter sqlParamQuestion = new OdbcParameter("@i_OptionId",SqlDbType.Int);
sqlParamQuestion.Value = rdoPollOptionList.SelectedValue;
sqlCmd.Parameters.Add(sqlParamQuestion);
sqlCmd.ExecuteNonQuery();
MyConnection.Close();
}
}
I i use stored procedure
for this u go site..http://www.beansoftware.com/asp.net-tutorials/poll-application.aspx
actully the project in vb i convert it in c# with mysql plz help me more
Thanks & regard.
yes i have a table with coloumn 'Answer'.
u see the link http://www.beansoftware.com/asp.net-tutorials/poll-application.aspx
for table .I convert only it in mysql
THIS IS THE ERROR
Column 'Answer' does not belong to table Table.
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.
Exception Details: System.ArgumentException: Column 'Answer' does not belong to table Table.
Source Error:
Line 54:
Line 55:
Line 56: throw ex;
Line 57: }
Line 58: }
Source File: c:\Inetpub\wwwroot\Polls-CS\Poll.aspx.cs Line: 56
Stack Trace:
[ArgumentException: Column 'Answer' does not belong to table Table.]
Poll.DisplayPoll() in c:\Inetpub\wwwroot\Polls-CS\Poll.aspx.cs:56
Poll.Page_Load(Object sender, EventArgs e) in c:\Inetpub\wwwroot\Polls-CS\Poll.aspx.cs:16
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627