I tried to find out were this issue is from even after debugging it, yet same error
Server Error in '/' Application.
Column '[Quantity_Remaining]' does not belong to 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 '[Quantity_Remaining]' does not belong to table .
Source Error:
Line 85: Panel pn = (Panel)ddlitemname.FindControl("Panelalert");
Line 86: pn.Visible = true;
Line 87: lblMessage2.Text = dt.Rows[0]["[Quantity_Remaining]"].ToString();
Line 88: }
Line 89: private DataTable GetDataTable(string query)
my table
CREATE TABLE [dbo].[SalesPoint](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Store] [nvarchar](50) NULL,
[ItemName] [nvarchar](120) NULL,
[Category] [nvarchar](120) NULL,
[Row] [float] NULL,
[Quantity_Recieved] [float] NULL,
[Quantity_Remaining] [float] NULL,
[Date_Recieved] [date] NULL CONSTRAINT [DF_SalesPoint_DateRecieved] DEFAULT (getdate()),
CONSTRAINT [PK_SalesPoint] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
code
protected void ddlitemname_SelectedIndexChanged(object sender, EventArgs e)
{
DataTable dt = GetDataTable("SELECT [Quantity_Remaining] FROM SalesPoint WHERE ItemName = '" + ddlitemname.SelectedItem.Text.Trim() + "'");
Panel pn = (Panel)ddlitemname.FindControl("Panelalert");
pn.Visible = true;
lblMessage2.Text = dt.Rows[0]["[Quantity_Remaining]"].ToString();
}
private DataTable GetDataTable(string query)
{
DataTable dt = new DataTable();
using (SqlConnection con = new SqlConnection())
{
con.ConnectionString = str;
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
cmd.CommandText = query;
con.Open();
using (SqlDataAdapter da = new SqlDataAdapter())
{
da.SelectCommand = cmd;
da.Fill(dt);
}
con.Close();
}
}
return dt;
}