Microsoft Database Engines

SQL Server
SQL Server Express
SQL Server Compact
LocalDB: LocalDB is the full SQL Server Express engine, but invoked directly from the client provider. It is a replacement of the current “User Instance” feature in SQL Server Express.


Convert timestamp to string

/// <summary>
/// Converts a timestamp to a hexadecimal string proceeded by 0x (to show it's a hexadecimal value)
/// </summary>
/// <param name="timestamp">The timestamp to be converted</param>
/// <returns>A hexadecimal string (proceeded by 0x)</returns>
public static string TimestampToString(System.Data.Linq.Binary timestamp)
  Byte[] bytes;
  string ts = "";
  bytes = timestamp.ToArray();
  foreach (Byte b in bytes)
    ts += b.ToString("X").PadLeft(2, Convert.ToChar("0"));
  return "0x" + ts; // This will not work with the function below, only to show. Use 'return ts;' to use with function below

Convert string to timestamp

public static System.Data.Linq.Binary StringToTimestamp(string s)
  char[] arr = s.ToCharArray();
  byte[] result = new byte[8];
  for (int i = 0; i < 8; i++)
    string t = string.Format("{0}{1}", arr[(i * 2)], arr[(i * 2) + 1]);
    result[i] = byte.Parse(t, System.Globalization.NumberStyles.HexNumber);
  return result;

To support rollback, you need to enable transactions

Switch on transactions (MSDTC)

Configuratiescherm (Control Panel) - Systeembeheer (Administrative Tools) - Component services
In Component services: go to Component services - Computers - Deze computer
Right click on Deze computer, choose Eigenschappen.
Go to the tab MSDTC
Click on Beveiligingsconfiguratie.
DTC-netwerktoegang: selected
Externe clients toestaan: selected, Extern beheer toestaan: selected
Inkomend verkeer toestaan: selected, Uitgaand verkeer toestaan: selected
Select Wederzijdse verificatie is vereist
TIP-transacties: selected
XA-transacties inschakelen: not selected (update 2013-08-22: start test with this setting selected)

Windows 7:

In Component services: go to Component services - Computers - Mijn computer - Distributed Transaction Coordinator - Lokale DTC
Right click on Lokale DTC, choose Eigenschappen.
Go to the tab Beveiliging.
See above for settings.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License