<%@ Page Language="C#" MasterPageFile="~/MasterPage/cloth.master" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" Title="Login" %>
my code is
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class Login : System.Web.UI.Page
{
DataSet ds = new DataSet();
DataSet dss = new DataSet();
Marvel mar = new Marvel();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void img_Click1(object sender, ImageClickEventArgs e)
{
string User = txtusername.Text;
string Pass = txtpassword.Text;
string qry = "select UserName,Password from Account where CompanyName='"+DropDownList1.SelectedItem.Text.ToString()+"'";
ds = mar.GETDS(qry);
if (ds.Tables[0].Rows != null)
{
for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
{
if ((User == ds.Tables[0].Rows[i]["UserName"].ToString()) && (Pass == ds.Tables[0].Rows[i]["Password"].ToString()) && (ds.Tables[0].Rows[i]["CompanyName"].ToString() == "Birmandam"))
{
Response.Redirect("~/Admin/Report.aspx");
}
else if (ds.Tables[0].Rows[i]["CompanyName"].ToString() == "Riyas")
{
if ((User == ds.Tables[0].Rows[i]["UserName"].ToString()) && (Pass == ds.Tables[0].Rows[i]["Password"].ToString()))
Response.Redirect("ForgotPassword.aspx");
}
else if (ds.Tables[0].Rows[i]["CompanyName"].ToString() == "Saravanas")
{
if ((User == ds.Tables[0].Rows[i]["UserName"].ToString()) && (Pass == ds.Tables[0].Rows[i]["Password"].ToString()))
Response.Redirect("Stockentry.aspx");
}
else
{
label.Text = "UserName/Password is Incorrect";
}
}
}
}
protected void LinkButton1_Click1(object sender, EventArgs e)
{
Response.Redirect("ForgotPassword.aspx");
}
}
it throws this error
Server Error in '/Login' Application.
Column 'CompanyName' 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 'CompanyName' does not belong to table Table.
Source Error:
| Line 40: } Line 41: Line 42: else if (ds.Tables[0].Rows[i]["CompanyName"].ToString() == "Riyas") Line 43: { Line 44: if ((User == ds.Tables[0].Rows[i]["UserName"].ToString()) && (Pass == ds.Tables[0].Rows[i]["Password"].ToString())) |
Source File: d:\selvi\Login\Login.aspx.cs Line: 42

sudipta sanyalPosted May 5, 2014, 8:01 AM
you populate a dataset by using
string qry = "select UserName,Password from Account where CompanyName='"+DropDownList1.SelectedItem.Text.ToString()+"'";
ds = mar.GETDS(qry);
so your dataset have "UserName","Password" column but you try to check (ds.Tables[0].Rows[i]["CompanyName"].ToString() == "Birmandam")) name CompanyName that column doesnot exists in your current dataset for this reason you got an error "Column 'CompanyName' does not belong to table Table"
so please check you code properly
Ish BandhuPosted May 5, 2014, 6:12 AM
select UserName,Password,CompanyName from Account where CompanyName='"+DropDownList1.SelectedItem.Text.ToString()+"'";