我班有什麼問題嗎?我只想大寫首字母和小寫字母。 我得到一個錯誤消息文本框的第一個字母標題案例
無法從空轉變爲對象
這是我的課:下面
class UpperCaseFirstLetter
{
private string text;
public void SetText(Control control)
{
text = control.Text;
text = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(text.ToLower());
}
代碼是我使用的類:
newConnection.ConnectionM();
SqlCommand cmd = SqlConnectionOLTP.cn.CreateCommand();
cmd.CommandText = "Insert into CostCategory(CostCategoryName,Description) values (@costcategoryname,@description)";
cmd.Parameters.AddWithValue("@costcategoryname",Format.SetText(textBoxCostName));
cmd.Parameters.AddWithValue("@description", textBoxCostDescription.Text);
cmd.ExecuteNonQuery();
SqlConnectionOLTP.cn.Close();
MessageBox.Show("Save");