วันอังคารที่ 24 ธันวาคม พ.ศ. 2567

SQL server ทั้ง ตัวเต็มและ localdb ลงไม่ได้ เพราะ harddisk มี Sector size มากกว่า 4K

เป็นปัญหา สำหรับเครื่องรุ่นใหม่ กับ Sql server 2019-... ลงได้ และ Start ไม่ได้ จาก Sector size >4Kให้แก้ Registry ตาม Link นี้



https://learn.microsoft.com/en-us/troubleshoot/sql/database-engine/database-file-operations/troubleshoot-os-4kb-disk-sector-size


ดูขนาด Sector
fsutil fsinfo sectorinfo <volume pathname>


คำสั่ง registry จาก CMD
REG ADD "HKLM\SYSTEM\CurrentControlSet\Services\stornvme\Parameters\Device" /v "ForcedPhysicalSectorSizeInBytes" /t   REG_MULTI_SZ /d "* 4095" /f

REG QUERY "HKLM\SYSTEM\CurrentControlSet\Services\stornvme\Parameters\Device" /v "ForcedPhysicalSectorSizeInBytes"

คำสั่ง Validate ว่า ใช้ได้




วันอังคารที่ 3 ธันวาคม พ.ศ. 2567

วันพุธที่ 18 กันยายน พ.ศ. 2567

Mongo compass query

 

find postfix

{

  "originalFileName": {

    "$regex": "\\.zip",

    "$options": "i"

  }

}


is exist

{ "originalFileName": { "$exists": true } }

วันเสาร์ที่ 17 สิงหาคม พ.ศ. 2567

Set Visual studio 202x และ dotnet core netcore 8 ไม่ Append output path

 ให้เปิด .csproj และ เพิ่ม 

<PropertyGroup>

   <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>

   <AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>

 </PropertyGroup>


วันพฤหัสบดีที่ 1 สิงหาคม พ.ศ. 2567

Set sql server 2019 ให้ ทำงานกับ JSON data

 ต้อง Set database ทีทำงานให้ support ก่อน

ALTER DATABASE MYDB SET COMPATIBILITY_LEVEL = 130


CREATE TABLE [dbo].[Orders](

[OrderID] [int] NOT NULL,

[CustomerName] [nvarchar](50) NULL,

[OrderDetails] [nvarchar](max) NULL)



INSERT INTO Orders (OrderID, CustomerName, OrderDetails)

VALUES (1, 'John test', 

'{"items": [{"name": "Widget", "quantity": 2}, 

            {"name": "Gizmo", "quantity": 4}], 

  "total": 99.99}')


INSERT INTO Orders (OrderID, CustomerName, OrderDetails)

VALUES (2, 'betty ok', 

'{"items": [{"name": "Pen", "quantity": 3}, 

            {"name": "Gizmo", "quantity": 2}], 

  "total": 88}')


ทดสอบ query

SELECT *

FROM Orders

WHERE EXISTS (

   SELECT *

   FROM OPENJSON(OrderDetails, '$.items')

   WHERE JSON_VALUE(value, '$.name') = 'Widget'

)

        

วันอาทิตย์ที่ 30 มิถุนายน พ.ศ. 2567

วันจันทร์ที่ 25 มีนาคม พ.ศ. 2567

Inno script ใช้ AfterInstall สำหรับ copy เข้า ที่ appdata

 ระวัง เรื่อง MsgBox จะเป็น  text,type,MB_OK .. ถ้าไม่ถูกจะ type mismatch และ ถ้าใช้ {userappdata} จะใส่ Rorming แล้ว


Pascal Scripting: BeforeInstall and AfterInstall Parameters

There are two optional parameters that are supported by all sections whose entries are separated into parameters except for [Languages], [Types], [Components] and [Tasks]. These are:

BeforeInstall

The name of a function that is to be called once just before an entry is installed. The function must either be a custom function in the [Code] section or a support function.

May include a comma separated list of parameters that Setup should pass to the function. Allowed parameter types are String, Integer and Boolean. String parameters may include constants. These constants will not be automatically expanded. If you want to pass an expanded constant, there's one special support function that may be called from within a parameter list for this: ExpandConstant.

Example:
[Files]
Source: "MYPROG.EXE"; DestDir: "{app}"; BeforeInstall: MyBeforeInstall
Source: "A\MYFILE.TXT"; DestDir: "{app}"; BeforeInstall: MyBeforeInstall2('{app}\A\MYFILE.TXT')
Source: "B\MYFILE.TXT"; DestDir: "{app}"; BeforeInstall: MyBeforeInstall2('{app}\B\MYFILE.TXT')
Source: "MYPROG.CHM"; DestDir: "{app}"; BeforeInstall: Log('Before MYPROG.CHM Install')
AfterInstall

The name of a function that is to be called once just after an entry is installed. The function must either be a custom function in the [Code] section or a support function.

May include a comma separated list of parameters that Setup should pass to the function. Allowed parameter types are String, Integer and Boolean. String parameters may include constants. These constants will not be automatically expanded. If you want to pass an expanded constant, there's one special support function that may be called from within a parameter list for this: ExpandConstant.

Example:
[Files]
Source: "MYPROG.EXE"; DestDir: "{app}"; AfterInstall: MyAfterInstall
Source: "A\MYFILE.TXT"; DestDir: "{app}"; AfterInstall: MyAfterInstall2('{app}\A\MYFILE.TXT')
Source: "B\MYFILE.TXT"; DestDir: "{app}"; AfterInstall: MyAfterInstall2('{app}\B\MYFILE.TXT')
Source: "MYPROG.CHM"; DestDir: "{app}"; AfterInstall: Log('After MYPROG.CHM Install')

All BeforeInstall and AfterInstall functions must not have a return value.

BeforeInstall or AfterInstall function isn't called if Setup already determined the entry shouldn't be processed.

BeforeInstall or AfterInstall function for a [Files] section entry using a wildcard but not the external flag is called once per file matching the wildcard, instead of once per entry. Use CurrentFileName to check for which file the function is called.

Here is an example of a [Code] section containing the functions used above. Functions CurrentFileName and Log are support functions and therefore not included in this [Code] section.

[Code]
procedure MyBeforeInstall();
begin
  MsgBox('About to install MyProg.exe as ' + CurrentFileName + '.', mbInformation, MB_OK);
end;

procedure MyBeforeInstall2(FileName: String);
begin
  MsgBox('About to install ' + FileName + ' as ' + CurrentFileName + '.', mbInformation, MB_OK);
end;

procedure MyAfterInstall();
begin
  MsgBox('Just installed MyProg.exe as ' + CurrentFileName + '.', mbInformation, MB_OK);
end;

procedure MyAfterInstall2(FileName: String);
begin
  MsgBox('Just installed ' + FileName + ' as ' + CurrentFileName + '.', mbInformation, MB_OK);
end;        
[Files]
Source: "source_path\pebim.addin"; DestDir: "{app}"; Flags: ignoreversion

[Code]
procedure CurStepChanged(CurStep: TSetupStep);
var
  UserAppDataPath: string;
  RevitPluginPath: string;
  PebimAddinSource: string;
  PebimAddinDest: string;
begin
  if CurStep = ssPostInstall then
  begin
    // Construct the path to the user's AppData\Roaming folder
    UserAppDataPath := ExpandConstant('{userappdata}');
    
    // Define the path to the Revit plugins folder
    RevitPluginPath := UserAppDataPath + '\Autodesk\Revit\Addins\2017';
    
    // Define the source and destination paths for pebim.addin
    PebimAddinSource := ExpandConstant('{app}\pebim.addin');
    PebimAddinDest := RevitPluginPath + '\pebim.addin';
    
    // Check if the Revit plugins folder exists
    if DirExists(RevitPluginPath) then
    begin
      // If the folder exists, copy pebim.addin to it
      if not FileCopy(PebimAddinSource, PebimAddinDest, False) then
      begin
        MsgBox('Failed to copy pebim.addin to the Revit plugins folder.', mbError, MB_OK);
      end;
    end;
  end;
end;