Posts

Showing posts from 2019

Automating DB Backup under SQL Server Express (Without SQL Agent)

SQL Server Express does not include SQL Server Agent. That means: No Jobs engine No Maintenance Plans (Management → Maintenance Plans does not exist) The same applies to many shared SQL Server environments. If you need automated backups, you must implement your own scheduling solution. The Solution Create a batch file and schedule it using Windows Task Scheduler . The script: Accepts database name as parameter Accepts backup folder as parameter Generates timestamped filename Executes BACKUP DATABASE via sqlcmd Batch File Script @echo off set databaseName=%1 echo %databaseName% set backupFolder=%2 echo %backupFolder% for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a" set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%" set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%...

Decimal number issue from server to client. Wow! Didn't expect this @_@

Image
Chapter 17   where a poor Decimal Number came from Server Side to JavaScript I worked on a page for days, adjusting the UI with CSS and HTML. Everything looked fine… until I started testing multi-lingual support. English — OK. Spanish — OK. Chinese — OK. Even right-to-left Hebrew (crooked and askew, but working). But Russian? Nope. In Russian the page stopped working completely: only static texts and images were visible. Nothing dynamic rendered. Of course it was a JavaScript error. Firefox DevTools showed this: That error led me to this JS code: I stared at those lines and saw nothing wrong — no missing variables, no typos, nothing obvious. I went to the original project code to find the exact non-rendered rows and noticed a server variable embedded into the client-side script: Which naturally led me to the server-side C# code responsible for generating that value: Nothing looked wrong there either. So I did what every developer does in ...

Configuring IIS to Allow CORS Requests (Fixing AJAX Calls to an API)

Image
The problem: sending AJAX requests from an HTML5 application running on my local machine to an API hosted under IIS (Google Cloud). The Setup Client: HTML/JS app on local machine Server: API under IIS (Google Cloud) The request looked like this: $.post({ url: apiEndpoint + "Init", contentType: "application/json; charset=utf-8", data: data, success: function (response) { logResponse("API response [Init]", response.d); }, error: function (xhr, status, error) { logResponse('Fail to call init API', data); } }); The error looked like this: Originally, there was crossDomain: true in the AJAX request, but it didn’t help. There were also crossdomain.xml and clientaccesspolicy.xml on the server — also useless for this case. What I Tried (And Why It Didn’t Help) I found many client-side “solutions” for AJAX, but they did not solve the issue....