Procedure Medien_DA_Erzeugen_DBC();
var
sel_s :
String;
upd_cmd : OleDbCommand;
upd_par : OleDbParameter;
ins_cmd : OleDbCommand;
ins_par : OleDbParameter;
del_cmd : OleDbCommand;
del_par : OleDbParameter;
begin
//Select
//Select String
sel_s := '
SELECT * FROM GFC_Medien';
//Daten aus der DB holen
g_c_medien_da := OleDbDataAdapter.Create(sel_s, gf_conn);
//Update
//Update Command
upd_cmd := OleDbCommand.Create();
upd_cmd.CommandType := CommandType.StoredProcedure;
upd_cmd.CommandText := '
GFC_M_UPDATE';
upd_cmd.Connection := gf_conn;
upd_cmd.Parameters.Clear;
upd_cmd.Parameters.Add('
@GFC_M_NAME', OleDbType.VarWChar, 100, '
GFC_M_NAME');
upd_cmd.Parameters.Add('
@GFC_M_AKTIV', OleDbType.Boolean, 1, '
GFC_M_AKTIV');
upd_cmd.Parameters.Add('
@GFC_M_OUT', OleDbType.Boolean, 1, '
GFC_M_OUT');
upd_cmd.Parameters.Add('
@GFC_M_USER_NAME', OleDbType.VarWChar, 50, '
GFC_M_USER_NAME');
upd_cmd.Parameters.Add('
@GFC_M_USER_TXT', OleDbType.LongVarWChar, 16, '
GFC_M_USER_TXT');
upd_cmd.Parameters.Add('
@GFC_M_USER_DATE', OleDbType.DBTimeStamp, 4, '
GFC_M_USER_DATE');
upd_par := upd_cmd.Parameters.Add('
@ID', OleDbType.Integer);
upd_par.SourceColumn := '
ID';
upd_par.SourceVersion := DataRowVersion.Current;
//Insert
//Insert Command
ins_cmd := OleDbCommand.Create();
ins_cmd.CommandType := CommandType.StoredProcedure;
ins_cmd.CommandText := '
GFC_M_INSERT';
ins_cmd.Connection := gf_conn;
ins_cmd.Parameters.Clear;
ins_cmd.Parameters.Add('
@GFC_M_NAME', OleDbType.VarWChar, 100, '
GFC_M_NAME');
ins_cmd.Parameters.Add('
@GFC_M_AKTIV', OleDbType.Boolean, 1, '
GFC_M_AKTIV');
ins_cmd.Parameters.Add('
@GFC_M_OUT', OleDbType.Boolean, 1, '
GFC_M_OUT');
ins_cmd.Parameters.Add('
@GFC_M_USER_NAME', OleDbType.VarWChar, 50, '
GFC_M_USER_NAME');
ins_cmd.Parameters.Add('
@GFC_M_USER_TXT', OleDbType.LongVarWChar, 16, '
GFC_M_USER_TXT');
ins_cmd.Parameters.Add('
@GFC_M_USER_DATE', OleDbType.DBTimeStamp, 4, '
GFC_M_USER_DATE');
ins_par := ins_cmd.Parameters.Add('
@Identity', OleDbType.Integer, 4, '
ID');
ins_par.Direction := System.Data.ParameterDirection.Output;
ins_par.SourceColumn := '
ID';
ins_par.SourceVersion := DataRowVersion.Current;
//Delete
//Delete Command
del_cmd := OleDbCommand.Create();
del_cmd.CommandType := CommandType.StoredProcedure;
del_cmd.CommandText := '
GFC_M_DELETE';
del_cmd.Connection := gf_conn;
del_cmd.Parameters.Clear;
del_par := del_cmd.Parameters.Add('
@ID', OleDbType.Integer, 4, '
ID');
del_par.SourceColumn := '
ID';
del_par.SourceVersion := DataRowVersion.Original;
//Commands übergeben
g_c_medien_da.UpdateCommand := upd_cmd;
g_c_medien_da.InsertCommand := ins_cmd;
g_c_medien_da.DeleteCommand := del_cmd;
//Daten ins Dataset
gf_conn.Open;
g_c_medien_da.Fill(g_c_dataset_ds, '
GFC_Medien');
gf_conn.Close;
//DataTable laden
g_c_medien_dt := g_c_dataset_ds.Tables['
GFC_Medien'];
end;