The User label after the Dear User will change accordingly to the user currently logged in , through the code from lblcName.Text = detail;
亲爱的用户之后的用户标签将通过lblcName.Text = detail的代码相应地更改为当前登录的用户;
and i've create a code for the iCount , Viewer and Time to change based on the User logged in , getting the User data and display it here. but the Label didnt change.. anywhere in this code i might do wrong?
我根据登录的用户创建了iCount,Viewer和Time的代码,获取用户数据并在此处显示。但标签没有改变..在这个代码中的任何地方我可能会做错?
debugging by putting breakpoint
on DataRow firstRow = dtC.Rows[0];
shows that my label
for iCount
value is 1 , but did not change the value , and the viewer
and time
label
value is also Viewer and Time
通过在DataRow firstRow = dtC.Rows [0]上放置断点进行调试;显示我的iCount值标签为1,但没有更改该值,查看器和时间标签值也是查看器和时间
public partial class Notification : Form
{
public Notification(string detail)
{
InitializeComponent();
lblcName.Text = detail;
}
private void Notification_Load(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Data Source=PEWPEWDIEPIE\\SQLEXPRESS;Initial Catalog=master;Integrated Security=True";
conn.Open();
DataTable dtC = new DataTable();
SqlDataAdapter daCount = new SqlDataAdapter("select iCount,LastView,Viewtime from ComDet where cName = @cName", conn);
daCount.SelectCommand.Parameters.Add("@cName", SqlDbType.VarChar).Value = lblcName.Text;
daCount.Fill(dtC);
DataRow firstRow = dtC.Rows[0];
lblCount.Text = firstRow["iCount"].ToString();
lblLastView.Text = firstRow["LastView"].ToString();
lblView.Text = firstRow["ViewTime"].ToString();
conn.Close();
}
}
1 个解决方案
#1
0
First, make sure that the database is not empty. Second, Use the Validate() method of the form that refreshes the form's controls.
首先,确保数据库不为空。其次,使用刷新表单控件的表单的Validate()方法。
#1
0
First, make sure that the database is not empty. Second, Use the Validate() method of the form that refreshes the form's controls.
首先,确保数据库不为空。其次,使用刷新表单控件的表单的Validate()方法。