Forum > Databases
Component to sdf file - Microsoft SQL Server database
paweld:
In the previous version, there is a bug related to the formatting of the date when adding a record - the database accepts the format yyyy-mm-dd, so as in the system was different it threw an error. Attached is the new version, and below is just the modified function:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function TForm2.ValueToSql(idx: Integer): String;var cn: ShortString; i, j: Integer; fs: TFormatSettings;begin fs.DecimalSeparator := '.'; fs.ShortDateFormat := 'yyyy/mm/dd'; fs.DateSeparator := '-'; fs.LongTimeFormat := 'hh:nn:ss'; fs.TimeSeparator := ':'; Result := ''; case Form1.tablestruct[idx]._type of 'int', 'bigint', 'numeric', 'decimal', 'float': cn := 'TFloatSpinEdit'; 'varchar', 'char', 'nvarchar', 'nchar': cn := 'TEdit'; 'text', 'ntext': cn := 'TMemo'; 'date', 'time', 'datetime': cn := 'TDateTimePicker'; end; j := -1; for i := 0 to Panel1.ComponentCount - 1 do begin if Panel1.Components[i].ClassName = cn then begin if Panel1.Components[i].Tag = idx then begin j := i; break; end; end; end; case Form1.tablestruct[idx]._type of 'int', 'bigint', 'numeric', 'decimal', 'float': Result := FormatFloat('0.######', TFloatSpinEdit(Panel1.Components[j]).Value, fs); 'varchar', 'char', 'nvarchar', 'nchar': Result := '''' + StringReplace(TEdit(Panel1.Components[j]).Text, '''', '''''', [rfReplaceAll]) + ''''; 'text', 'ntext': Result := '''' + StringReplace(TMemo(Panel1.Components[j]).Lines.Text, '''', '''''', [rfReplaceAll]) + ''''; 'date': Result := '''' + DateToStr(TDateTimePicker(Panel1.Components[j]).Date, fs) + ''''; 'time': Result := '''' + TimeToStr(TDateTimePicker(Panel1.Components[j]).Time, fs) + ''''; 'datetime': Result := '''' + DateTimeToStr(TDateTimePicker(Panel1.Components[j]).DateTime, fs) + ''''; end;end;
Navigation
[0] Message Index
[*] Previous page