我想通过点击datagridview控件中的datagridviewlinkcolumn,来实现打开数据库中的文件
但是我这一段始终不能实现
最后提示错误为invalidOperationException尚未提供文件名,所以无法启动谁能救救我啊···private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {            SqlConnection conn = new SqlConnection();
            conn.ConnectionString = "Server=PC-201106241704;Integrated Security=True;" + "DataBase=chengdu";
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = conn;            cmd.CommandText = "Select 文件, 文件 from XSdcTable"; 
            FileStream fs;
            BinaryWriter bw;
            int buffersize = 100;
            byte[] outbyte = new byte[buffersize];
            long reval;
            long startIndex;
            string filePath = @"C:/wordData.doc";
            conn.Open();
            SqlDataReader reader;
            reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                fs = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write);
                bw = new BinaryWriter(fs);
                startIndex = 0;
                reval = reader.GetBytes(0, startIndex, outbyte, 0, buffersize);
                while (reval == buffersize)
                {
                    bw.Write(outbyte);
                    bw.Flush();
                    startIndex += buffersize;
                    reval = reader.GetBytes(0, startIndex, outbyte, 0, buffersize);
                }
                bw.Write(outbyte, 0, (int)reval );
                bw.Flush();
                bw.Close();
                fs.Close();
            }
            reader.Close();
            conn.Close();
            for (int i = 0; i < dataGridView2.Rows.Count; i++)
            {
                if (e.ColumnIndex != 0)
                {
                    System.Diagnostics.Process.Start(dataGridView2.Rows[i].Cells[0].Value.ToString());
                }
            }
        } 

解决方案 »

  1.   

    把这帖子移到.NET版就行了,还在那边重新开了一帖!= =
      

  2.   

    去.net板块吧,CS模块用的比较少。关注
      

  3.   

    弱弱的问下:SQL查询能有中文字段吗?
      

  4.   

    对数据库的数据操作无什么问题,问题应该是出在文件读写操作上.
    建议逐语句debug,找出错误的语句
      

  5.   

    感觉好像是
    System.Diagnostics.Process.Start(dataGridView2.Rows[i].Cells[0].Value.ToString());
    出的错,LZ你后面那些格子里都有值吗?是绝对路径吗?为嘛要启动这么多进程