这是我的代码:
public userScreen(string uName)
{
InitializeComponent();
userName = uName;
string topLogNumber = "0";
textBox2.Text = userName;
Conversion(topLogNumber);
textBox1.Text = topLogNumber;
this.WindowState = FormWindowState.Maximized;
private string Conversion(string lognumber)
{
lognumber = gettoplognumber();
int lognumberint = Convert.ToInt32(lognumber);
lognumberint = lognumberint+1;
lognumber = lognumberint.ToString();
return lognumber;
}
private string gettoplognumber()
{
string selectTopLogNumber = "SELECT MAX (LogNo) from Logs";
string connection = "Data Source = \"EventControl.sdf\"";
SqlCeConnection connexion = new SqlCeConnection(connection);
SqlCeCommand topLog = new SqlCeCommand(selectTopLogNumber, connexion);
try
{
connexion.Open();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
return "error";
}
return topLog.ExecuteScalar() as string;
现在,这段代码所做的是查看数据库并将数字加一。当它运行时(我已经调试了整个过程),由于某种原因一切都很好,直到它到达 textBox1.Text = topLogNumber; 此时它变回“”。任何人????