c#将图像从datagridview移动到数据集

时间:2015-06-16 14:40:37

标签: c# visual-studio-2013 datagridview

在我的程序中,我可以选择上传五张图片。我一直将它们存储在带有datagridview的表中

if (i < conTotal)
        {
            DataRow anyRow;

            anyRow = epasDataSet.ContaminationAreas.NewRow();
            anyRow[0] =  txtContaminationAreaName.Text;
            anyRow[1] = txtConArea.Text;
            anyRow[2] = dgdImages.Rows[0].Cells[1];
            anyRow[3] = dgdImages.Rows[0].Cells[0].Value;
 epasDataSet.ContaminationAreas.Rows.Add(anyRow);
            dataGridView1.Refresh();
        }

在datagridview中保存它们后,我希望在用户完成表单后将它们移动到我的数据集中的数据库

 Type of value has a mismatch with column typeCouldn't store <System.Drawing.Bitmap> in Photo 1 Column.  Expected type is Byte[].

但是,当我运行时,我收到以下错误消息

public class ConnectionManager extends UnicastRemoteObject implements Server
{
public List<ClientHandler> clients = Collections.synchronizedList(new ArrayList<>());
public ConnectionManager() throws RemoteException 
{
    super();
}

public static final String RMI_ID = "Server";

@Override
public boolean checkConnection() throws RemoteException 
{
    return true;
}

@Override
public int getPort(String ip) throws RemoteException
{
    int i = 10000+clients.size()*2;
    clients.add(new ClientHandler(ip, i));
    return i;
}
}

我不知道如何转换图像,还是有更好的方法来存储图像,直到它与数据库同步?

0 个答案:

没有答案