我現(xiàn)在正在學(xué)習(xí) C#。我從論壇復(fù)制了以下 C# 代碼。我了解編碼的作用及其語(yǔ)法。我需要知道編碼是否遵循 C# 的最佳實(shí)踐。connectionString = "Data Source=S9; " + "Initial Catalog=Hp;" + " Integrated Security=SSPI";sql = "Insert into tt(cr,TimeSpent_Min,Date,Empid) values (@p1,@p2,@p3,@p4)";connection.Open();command = new SqlCommand(sql, connection);command.Parameters.AddWithValue("@p1", textBox1.Text);command.Parameters.AddWithValue("@p2", textBox2.Text);command.Parameters.AddWithValue("@p3", textBox3.Text);command.Parameters.AddWithValue("@p4", textBox4.Text);command.ExecuteNonQuery();command.Dispose();connection.Close();MessageBox.Show("Successfully Inserted ");編輯問(wèn)題的清晰度:我問(wèn)這個(gè)問(wèn)題的原因是在大多數(shù)在線論壇中,他們提供了上述與數(shù)據(jù)庫(kù)連接的一般結(jié)構(gòu)。但解釋和最佳實(shí)踐不可用
- 1 回答
- 0 關(guān)注
- 239 瀏覽
添加回答
舉報(bào)
0/150
提交
取消