我做了一个数据库存图片的段子
 DataSet DS_3;        private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
        {
            try
            {
                Bitmap BMP = new Bitmap(openFileDialog1.FileName);
                pictureBox1.BackgroundImage = BMP;
                if (openFileDialog1.OpenFile() != null)
                {
                    Stream myStream = openFileDialog1.OpenFile();
                    int length = (int)myStream.Length;
                    byte[] bytes = new byte[length];
                    myStream.Read(bytes, 0, length);
                    myStream.Close();                    DS_3.Tables[0].Select("小区=" + dataGridView1.CurrentRow.Cells[dataGridView1.Columns["小区"].Index].Value)[0][DS_3.Tables[0].Columns.IndexOf("照片")] = bytes;
                    Show_Image();
                    Save_Image();
                }
            }
主要问题出在                    DS_3.Tables[0].Select("小区=" + dataGridView1.CurrentRow.Cells[dataGridView1.Columns["小区"].Index].Value)[0][DS_3.Tables[0].Columns.IndexOf("照片")] = bytes;这一句,当ataGridView1.CurrentRow.Cells[dataGridView1.Columns["小区"].Index].Value 的值全为数字的就没有问题(例如0024),而值为(例如 a0024)就提示找不到[a0024],不知道是哪里出了问题,请路人指点一下 谢谢!

解决方案 »

  1.   

    DataSet.Tables[].Select()怎么过滤列数据啊 难道只能是数字格式的吗?为什么我的数据如果有字母之类的就提示无效了呢?
      

  2.   

    当我改成    
    string xiaoqu = "小区='" + dataGridView1.CurrentRow.Cells[dataGridView1.Columns["小区"].Index].Value.ToString() + "'";
    DS_3.Tables[0].Select(xiaoqu)[0][DS_3.Tables[0].Columns.IndexOf("照片")] = bytes; 还是不行,“无效”错误道是不提示了 但图片框里面的图片无论我怎么选也不变了 当参数为int ID时就恢复正常了 弄了一上午了 不知道是哪里出了问题 真头痛!!!