protected override bool _internal_Write() { //Look if the Connection is still open.. try { string sql = "SELECT id FROM " + dataTable + " WHERE id = 0"; myCmd = new FbCommand(sql, myDBConn); myCmd.ExecuteNonQuery(); } catch (Exception) { myDBConn.Close(); //Verbindung schließen! myDBConn.Open(); if (myDBConn.State != System.Data.ConnectionState.Open) { Logging.LogText("Error ReConnecting to Database! Dataset:" + datasetConfig.Name, Logging.LogLevel.Error); return(false); } myDBConn.ChangeDatabase(myConfig.DatabaseFile); } //Add the Fields to the Database myCmd = new FbCommand(insertCommand, myDBConn); for (int n = 0; n < _maxAdd; n++) //foreach (IEnumerable<object> values in _intValueList) { myCmd.Parameters.Clear(); IEnumerable <object> values = _intValueList[n]; using (IEnumerator <DatasetConfigRow> e1 = fieldList.GetEnumerator()) using (IEnumerator <object> e2 = values.GetEnumerator()) { while (e1.MoveNext() && e2.MoveNext()) { //foreach (DatasetConfigRow field in fieldList) //{ DatasetConfigRow field = e1.Current; Object value = e2.Current; //values[fnr++]; switch (field.PLCTag.TagDataType) { case DotNetSiemensPLCToolBoxLibrary.DataTypes.TagDataType.LInt: case DotNetSiemensPLCToolBoxLibrary.DataTypes.TagDataType.LWord: case DotNetSiemensPLCToolBoxLibrary.DataTypes.TagDataType.Int: case DotNetSiemensPLCToolBoxLibrary.DataTypes.TagDataType.Dint: case DotNetSiemensPLCToolBoxLibrary.DataTypes.TagDataType.Word: case DotNetSiemensPLCToolBoxLibrary.DataTypes.TagDataType.Dword: case DotNetSiemensPLCToolBoxLibrary.DataTypes.TagDataType.Byte: case DotNetSiemensPLCToolBoxLibrary.DataTypes.TagDataType.BCDByte: case DotNetSiemensPLCToolBoxLibrary.DataTypes.TagDataType.BCDWord: case DotNetSiemensPLCToolBoxLibrary.DataTypes.TagDataType.BCDDWord: myCmd.Parameters.Add(new FbParameter("@" + field.DatabaseField, System.Data.DbType.String) { Value = value.ToString() }); break; case DotNetSiemensPLCToolBoxLibrary.DataTypes.TagDataType.Float: case DotNetSiemensPLCToolBoxLibrary.DataTypes.TagDataType.LReal: myCmd.Parameters.Add(new FbParameter("@" + field.DatabaseField, System.Data.DbType.String) { Value = value.ToString().Replace(',', '.') }); break; case DotNetSiemensPLCToolBoxLibrary.DataTypes.TagDataType.DateTime: myCmd.Parameters.Add(new FbParameter("@" + field.DatabaseField, System.Data.DbType.String) { Value = ((DateTime)value).ToString("dd-MM-yyyy HH:mm:ss") }); break; case DotNetSiemensPLCToolBoxLibrary.DataTypes.TagDataType.String: case DotNetSiemensPLCToolBoxLibrary.DataTypes.TagDataType.CharArray: myCmd.Parameters.Add(new FbParameter("@" + field.DatabaseField, System.Data.DbType.String) { Value = (String)value }); break; } } } int tryCounter = 0; nomol: try { myCmd.ExecuteNonQuery(); } catch (Exception ex) { throw ex; } } /* * //Ringpufferarchiv... * if (myProtokollDaten.MaxDatasets > 0) * { * string delstr = "DELETE FROM " + myProtokollDaten.DataBaseTable + " WHERE id <= (SELECT max(id) FROM " + myProtokollDaten.DataBaseTable + ") - (" + myProtokollDaten.MaxDatasets.ToString() + ")"; * myCmd.CommandText = delstr; * myCmd.ExecuteNonQuery(); * } */ return(true); }