我已经为我的localdatabse创建了一个文件上传器,它将成功地将任何类型的文件上传到我的localdatabse。但现在我需要使用我的网格视图。我怎样才能为特定的列和单元格做到这一点。
我的localdatabse文件上传器的代码
private void _tbnOpenImage_Click(object sender, EventArgs e)
{
OpenFileDialog fileChooser = new OpenFileDialog();
fileChooser.Filter = "ALL files (*.*)|*.*";
fileChooser.InitialDirectory = "C:/Users/Sreejithmohan/Pictures/sample pics/";
fileChooser.Title = "Uplaod Any File";
if(fileChooser.ShowDialog()==DialogResult.OK)
{
_PictureBox.ImageLocation = fileChooser.FileName;
}
}
private void _btnUpload_Click(object sender, EventArgs e)
{
SqlCeConnection cnn = new SqlCeConnection(Properties.Settings.Default.MyConnectionString);
byte[] imgData;
imgData = File.ReadAllBytes(_PictureBox.ImageLocation);
SqlCeCommand cmd = new SqlCeCommand("INSERT INTO Imagetbl (Pics) VALUES (@DATA)",cnn);
cmd.Parameters.Add("@DATA", imgData);
cnn.Open();
cmd.ExecuteNonQuery();
cnn.Close();
}