The C# code:
string str = "Data Source=(LocalDB)\\MSSQLLocalDB;";
str += "AttachDbFilename=|DataDirectory|DinoData.mdf;";
str += "Integrated Security= True";
SqlConnection c;
c = new SqlConnection(str);
if (Show.Text == "all" || Show.Text == "All" || Show.Text == "all table" || Show.Text == "All table" || Show.Text == "All Table" || string.IsNullOrWhiteSpace(Show.Text))
{
DataTable dt = new DataTable();
String req;
req = "SELECT * FROM [User] Where Username = "+Session["CurentUserid"];
SqlDataAdapter da = new SqlDataAdapter(req, c);
da.Fill(dt);
datagrid.DataSource = dt;
datagrid.DataBind();
}
else
{
if (!string.IsNullOrWhiteSpace(Show.Text))
{
DataTable dt = new DataTable();
String req;
req = Show.Text+ " Where Username = " + Session["CurentUserid"];
SqlDataAdapter da = new SqlDataAdapter(req, c);
da.Fill(dt);
datagrid.DataSource = dt;
datagrid.DataBind();
}
}
The error:
An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code
Additional information: Invalid column name 'Niss'.
Please help, Niss
is the id of one of my users