循环判断输入框哪个填了输入
用个字符串加起来

解决方案 »

  1.   

    "在数据库这些类"应是“属性”的吧。
    如果想动态生成SQL,就判断呗。现举个例子:
                //string sql = string.Format("insert into table1 (t1,t2,t3) values ({1},{2},{3})",t1,t2,t3);            string str1 = "";
                string str2 = "";            if (!string.IsNullOrEmpty(txtT1.Text.Trim()))
                {
                    str1 += "t1,";
                    str2 += txtT1.Text.Trim() + ",";
                }
                if (!string.IsNullOrEmpty(txtT2.Text.Trim()))
                {
                    str1 += "t2,";
                    str2 += txtT2.Text.Trim() + ",";
                } 
                if (!string.IsNullOrEmpty(txtT3.Text.Trim()))
                {
                    str1 += "t3";
                    str2 += txtT3.Text.Trim();
                }
                string sql = string.Format("insert into table1 ({0}) values ({1})", str1, str2);