源代码如下
 public string strID;
        public string strNum;
        public string strType;
        public string strCount;
        public string strProdution;
        public string strData;
        public string strPlace;
        public string strBranch;
        public string strBackup;
        public string strCharge;
        public string strName;
        public string strSql;
        public static int intCount = 0;//控制数据组索引
        public string [] strScoure = new string [9];//定义查询字符串数组
        public int intAdd;//用来判断SQL语句数组数量
        public void DatetimeJudge()
        {
            if (dateTimePicker1.Value > dateTimePicker2.Value)
            {
                MessageBox.Show("生产日期选择出错,请检查!");
            }
            if (dateTimePicker1.Value < dateTimePicker2.Value)
            {
                strData = "生产日期 between'"+dateTimePicker1.Value.Date+"'and'"+dateTimePicker2.Value.Date+"'";
            }
            if (dateTimePicker1.Value == dateTimePicker2.Value)
                strData = "生产日期='" + dateTimePicker1.Value.Date + "'";
        }
        public void GetScoure(string strSql)
        {
            if (p == 1)
            {
                MyMean.OpenCon();
                SqlCommand command4 = new SqlCommand(strSql, MyMean.MyCon);
                dataGridView1.Rows.Clear();
                SqlDataReader p_dataReader = command4.ExecuteReader();
                while (p_dataReader.Read())
                {
                    dataGridView1.Rows.Add(p_dataReader[0].ToString(),p_dataReader[1].ToString(),p_dataReader[2].ToString(),p_dataReader[3].ToString(),p_dataReader[4].ToString(),p_dataReader[5].ToString(),p_dataReader[6].ToString(),p_dataReader[7].ToString(),p_dataReader[8].ToString(),p_dataReader[9].ToString(),p_dataReader[10].ToString(),p_dataReader[11].ToString());
                }
                MyMean.CloseCon();            }        }
        private void button6_Click(object sender, EventArgs e)
        {
            if (p == 1)
            {
                intCount = 0;
                if (textBox1.Text != "")
                {
                    strName = "name like '%" + //定义SQL字符串
                    textBox1.Text + "%'";
                    strCount[intCount] = strName;
                    intCount++;
                }
                if (textBox2.Text != "")
                {
                    strNum = "编号 like '%" + //定义SQL字符串
                    textBox2.Text + "%'";
                    strCount[intCount] = strNum;
                    intCount++;
 
                }
                if (textBox3.Text != "")
                {
                    strType = "型号 like '%" + //定义SQL字符串
                    textBox3.Text + "%'";
                    strCount[intCount] = strType;
                    intCount++;
                }
                if (textBox4.Text != "")
                {
                    strProdution = "生产厂商 like '%" + //定义SQL字符串
                    textBox4.Text + "%'";
                    strCount[intCount] = strProdution;
                    intCount++;
                }
                if (textBox5.Text != "")
                {
                    strPlace = "安装地点 like '%" + //定义SQL字符串
                    textBox5.Text + "%'";
                    strCount[intCount] = strPlace;
                    intCount++;
                }
                if (textBox6.Text != "")
                {
                    strBranch = "所属部门 like '%" + //定义SQL字符串
                    textBox6.Text + "%'";
                    strCount[intCount] = strBranch;
                    intCount++;
                }
                if (textBox7.Text != "")
                {
                    strCharge = "负责人 like '%" + //定义SQL字符串
                    textBox7.Text + "%'";
                    strCount[intCount] = strCharge;
                    intCount++;
                }
                if (comboBox1.Text != "")
                {
                    strBackup = "生产厂商 like '%" + //定义SQL字符串
                    comboBox1.Text + "%'";
                    strCount[intCount] = strBackup;
                    intCount++;
                }
                if (checkBox1.Checked = true)
                {
                    DatetimeJudge();
                    strCount[intCount] = strData;
                    intCount++;
                }
                for (int i = 0; i < strScoure.Length; i++)//遍历字符串集合
                {
                    if (strScoure[i] != null)//判断字符是否为空
                    {
                        strSql += strScoure[i];//组合查询字符串
                        intAdd++;//开始记数
                    }
                }
                switch (intAdd)//使用多路选择语句组合查询语句
                {                    case 0:
                        strSql = "select * from 设备设施信息表";
                        break;
                    case 1:
                        strSql = "select * from 设备设施信息表 where " + strScoure[0];
                        break;
                    case 2:
                        strSql = "select * from 设备设施信息表 where " + strScoure[0] +
                            " and " + strScoure[1];
                        break;
                    case 3:                        strSql = "select * from 设备设施信息表 where " + strScoure[0] +
                            " and " + strScoure[1] + " and " + strScoure[2];
                        break;
                    case 4:
                        strSql = "select * from 设备设施信息表 where " + strScoure[0] +
                            " and " + strScoure[1] + " and " + strScoure[2] +
                            " and " + strScoure[3] + " and " + strScoure[4];
                        break;
                    case 5:
                        strSql = "select * from 设备设施信息表 where " + strScoure[0] +
                            " and " + strScoure[1] + " and " + strScoure[2] +
                            " and " + strScoure[3] + " and " + strScoure[4] + " and " + strScoure[5];
                        break;
                    case 6:
                        strSql = "select * from 设备设施信息表 where " + strScoure[0] +
                            " and " + strScoure[1] + " and " + strScoure[2] +
                            " and " + strScoure[3] + " and " + strScoure[4] + " and " + strScoure[5] + " and " + strScoure[6];
                        break;
                    case 7:
                        strSql = "select * from 设备设施信息表 where " + strScoure[0] +
                            " and " + strScoure[1] + " and " + strScoure[2] +
                            " and " + strScoure[3] + " and " + strScoure[4] + " and " + strScoure[5] + " and " + strScoure[6] + " and " + strScoure[7];
                        break;
                    case 8:
                        strSql = "select * from 设备设施信息表 where " + strScoure[0] +
                            " and " + strScoure[1] + " and " + strScoure[2] +
                            " and " + strScoure[3] + " and " + strScoure[4] + " and " + strScoure[5] + " and " + strScoure[6] + " and " + strScoure[7] + " and " + strScoure[8];
                        break;
                    case 9:
                        strSql = "select * from 设备设施信息表 where " + strScoure[0] +
                            " and " + strScoure[1] + " and " + strScoure[2] +
                            " and " + strScoure[3] + " and " + strScoure[4] + " and " + strScoure[5] + " and " + strScoure[6] + " and " + strScoure[7] + " and " + strScoure[8] + " and " + strScoure[9];
                        break;
                }
                GetScoure(strSql);//查询数据库中数据
                intAdd = 0;//记数器置0
                intCount = 0;//记灵器置0
                strSql = "";//重置SQL语句
                for (int i = 0; i < strScoure.Length; i++)
                {
                    if (strScoure[i] != null)
                    {
                        strScoure[i] = null;//清空字符串数组内容
                    }
                }            }
        }        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox1.Checked = true)
            {
                dateTimePicker1.Enabled = true;
                dateTimePicker2.Enabled = true;
            }
            else
            {
                dateTimePicker1.Enabled = false;
                dateTimePicker2.Enabled = false;
            }
        }运行后报错皆为
strCount[intCount] = XXXX;
                    intCount++;
处。
错误为:错误4无法对属性或索引器“string.this[int]”赋值 -- 它是只读的;错误5无法将类型“string”隐式转换为“char”求高手解惑,在另外一个例子程序中,这段代码完全没有任何问题,很是困惑啊