after 3 days of grafting ive managed to get the thing to work
if anyone is interested its as below:
procedure TfrmChooseOptions.DBGAvailableModulesDblClick(Send er: TObject);
var
sql: string;
AcadYear: string;
begin
AcadYear := '2008';
sql := 'INSERT INTO StudentOptionChoices ( StudentID, ModuleCode, semester, Academic_Year ) ' ;
sql := sql + ' VALUES (' + quotedstr(DBGStudentsList.datasource.dataset.Field ByName('studentID').AsString);
sql := sql + ', ' + quotedstr(DBGAvailableModules.datasource.dataset.F ieldByName('ModuleCode').AsString);
sql := sql + ', ' + DBGAvailableModules.datasource.dataset.FieldbyName ('semester').AsString;
sql := sql + ', ' + quotedstr(AcadYear) + ')' ;
DMStudentRecord.ADOCMOptionsChoices.CommandText := sql;
try
DMStudentRecord.ADOCMOptionsChoices.Execute;
RefreshDataChoices;
except
on E: Exception do showmessage( 'You have already added that module'); //E.Message);
the try/except statement does not allow duplicate data in the grid the double click moves it to
now to make a delete function work...
which is on the lines of:
sql := 'DELETE FROM StudentOptionsChoices ( StudentID, ModuleCode, semester, Academic_Year ) ' ;
sql := sql + ' WHERE studentID = ' + quotedstr(DBGStudentsList.datasource.dataset.Field byName('studentID').asstring);
sql := sql + ' AND ModuleCode = ' + quotedstr(DBGAvailableModules.datasource.dataset.F ieldByName('ModuleCode').AsString);
sql := sql + ' AND semester = ' + (DBGAvailableModules.datasource.dataset.FieldbyNam e('semester').AsString);
sql := sql + ' AND AcadYear = ' + quotedstr(AcadYear) + ')' ;
DMStudentRecord.ADOCMOptionsChoices.CommandText := sql;
try
DMStudentRecord.ADOCMOptionsChoices.Execute;
RefreshDataChosen;
finally
end;
or something like it...
thanks for all you help folks. feel free to post if youve any extra advice that may help
Alex