我有一个子程序来向sql server表插入一条记录.代码:
public void Insert_Met(int Counts, char Gender)
{
Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("@Counts", Counts);
parameters.Add("@Gender", Gender);
// run a stored procedure ExecuteNonQuery
}
Run Code Online (Sandbox Code Playgroud)
我的其他行代码,
int counts = Convert.ToInt32(numberUpdowncontrol1.Text);
// from a control, maybe empty then it is null.
Insert_Met(counts,'M');
Run Code Online (Sandbox Code Playgroud)
我的问题是有时Counts可以为null,那么如何更改我的代码呢?
谢谢,