我想显示当前登录用户的记录。我能够显示记录,但它显示已提交给系统的所有记录。我想要根据谁向数据库提交信息的记录。
这是我想要从
显示想法的页面的代码 // CONNECT TO THE DB
SqlConnection sqlCon = new SqlConnection(@"Data Source=ICS-40-JBONEY;Initial Catalog=TTXIdeaPortal;Integrated Security=True");
sqlCon.Open();
//CREATE A COMMAND
int userid = Convert.ToInt32(Session["UserCookie"]);
//SqlCommand sqlcmd = new SqlCommand("SELECT [IdeaTitle], [IdeaDescription], [How], [Why], [Category] FROM [dbo].[EmployeeIdeas]");
SqlCommand sqlcmd = new SqlCommand("ustpGetEmployeeIdeas");
//SqlCommand sqlcmd = new SqlCommand("SELECT * from EmployeeIdeas where EloginID = ");
//sqlcmd.CommandType = CommandType.Text = "SELECT * FROM list where user_id = " + userid + "";
sqlcmd.CommandType = CommandType.Text;
sqlcmd.Connection = sqlCon;
string ideaTitle = "";
string ideaDescription1 = "";
string how1 = "";
string why1 = "";
//READ FROM DB
SqlDataReader reader = sqlcmd.ExecuteReader();
while (reader.Read())
{
ideaTitle += reader["IdeaTitle"].ToString();
ideaDescription1 += reader["IdeaDescription"].ToString();
how1 += reader["How"].ToString();
why1 += reader["Why"].ToString();
}
sqlCon.Close();
Label1.Text = ideaTitle;
Label2.Text = ideaDescription1;
Label3.Text = how1;
Label4.Text = why1;
}
}
}