hi guys ,
1)i wrote this bunch of codes but i can't get any result from part update . this part should update those cells that user want to change it.
for example you want to change some music ranking so you must duble click on data gide viwe to update that cell and this part of this code must do this but when i calling this function ,nothing happening ... but why ?
private void AddingToLibrrary(bool Updata)
{
OleDbConnection obj_Connection = new OleDbConnection
(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\History.mdb");
OleDbCommand obj_Command = new OleDbCommand();
obj_Command.Connection = obj_Connection;
if (Updata == false)
{
obj_Command.CommandText = "INSERT INTO History (Name,Artist,Album,Address)" +
"values(@namefild,@ArtistFild,@AlbumFild,@AddressFild)";
obj_Command.Parameters.AddWithValue("@namefild", MusicTitle);
obj_Command.Parameters.AddWithValue("@ArtistFild", MusicArtist);
obj_Command.Parameters.AddWithValue("@AlbumFild", MusicAlbum);
obj_Command.Parameters.AddWithValue("@AddressFild", FileLoadingclass.FileName);
obj_Connection.Open();
obj_Command.ExecuteNonQuery();
obj_Connection.Close();
this.historyQTableAdapter.Fill(this.historyDataSet.HistoryQ);
}
else if (Updata == true)
{
obj_Command.CommandText = "UPDATE History SET Ranking WHERE ID = " + DGVHistory.RowCount.ToString();
try
{
int row_affected = obj_Command.ExecuteNonQuery();
this.historyQTableAdapter.Fill(this.historyDataSet.HistoryQ);
MessageBox.Show(row_affected.ToString(), "Update command result");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
thanks .