0
我試圖將一個圖像插入SQL Server數據庫,它進入數據集,但是當save方法被調用時,SQL Server不會更改。數據集將不會更新圖像數據庫
public void AddImage(OpenFileDialog openFileDialog1, List<Movie> movieList)
{
byte[] movieCover = null;
FileStream movieStream = new FileStream(openFileDialog1.FileName, FileMode.Open, FileAccess.Read);
BinaryReader movieReader = new BinaryReader(movieStream);
movieCover = movieReader.ReadBytes((int)movieStream.Length);
var Starwars = new object[2];
Starwars[0] = "Star Wars: Episode I - The Phantom Menace";
Starwars[1] = "1999";
var found = _movieSet.Tables["Movie"].Rows.Find(Starwars);
if (found != null)
{
found.SetField("Cover", movieCover);
var movieListFound = movieList.Find(x => x.Name == Starwars[0]);
}
else
MessageBox.Show("Movie Not Found");
}
的保存方法
public void Save()
{
var movieConnection = new SqlConnection();
try
{
movieConnection = new SqlConnection(Properties.Settings.Default.moviesConnectionString);
movieConnection.Open();
_movieAdapter.Update(_movieSet, "Movie");
movieConnection.Close();
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
finally
{
movieConnection.Dispose();
}
}
添加新行工作,但沒有更新任何類型的變化對實際數據集時的保存方法被調用,不只是形象,但如果我更改表數據可視化器在調試數據。