SQL statement handle is not initialized
Category: LuaScript | Subcategory: SQL Statement
🆘 What does this error mean?
This error appears when the server (emulator) cannot prepare an SQL query because a valid database connection was not established.
📌 Common causes
# The GameServer.lua file is misconfigured.
* Incorrect use of DataBase.Connect() or Connect2().
* The SQL Server is down or unreachable from the emulator.
* ODBC is missing or misconfigured (invalid or missing DSN).
* Wrong credentials or blocked network ports (like 1433).
🧪 Step-by-step solution
✅ Step 1: Check your GameServer.lua file
# Local connection
DataBase.Connect(3, "MuOnlineS6", "sa", "PASS_SQL")
# Remote connection without ODBC (uncomment if needed):
DataBase.Connect2("127.0.0.1", 1433, "MuOnlineS6", "sa", "PASS_SQL")
Make sure only one connection line is active.
Double-check the database name, username, and password.
✅ Step 2: Are you using ODBC or direct connection?
If using ODBC: confirm that the DSN exists and works using Windows ODBC Data Source Administrator.
If connecting from another VPS or without ODBC: use Connect2() and ensure SQL Server allows remote connections and port 1433 is open.
✅ Step 3: Test the connection
Try connecting manually using tools like SSMS, DBeaver, or sqlcmd.
Make sure SQL Server and firewall settings allow external access.
📘 ODBC example
DataBase.Connect(3, "MuOnlineS6", "sa", "1234")
MuOnlineS6 (Database Name) - sa (Username SQL) - 1234 (Password SQL)
📘 Without ODBC example
DataBase.Connect2("192.168.0.100", 1433, "MuOnlineS6", "sa", "1234")
192.168.0.100 (Public IP Connection) - 1433 (PORT Connection SQL) - MuOnlineS6 (Database Name) - sa (Username SQL) - 1234 (Password SQL)
❗ What happens if I don’t fix it?
The emulator will automatically shut down (SafeExitProcess) and you won’t be able to proceed until a valid SQL database connection is established.
✅ What should I do now?
1- Open the GameServer.lua file located in KG_Data/Scripts/.
2- Fix the connection line according to your setup:
- Use Connect() if using ODBC.
- Use Connect2() if not using ODBC or connecting from another VPS.
3- Make sure the database exists and your credentials are correct.
4- Open GameServer.exe again.
If the connection is valid, the server should start successfully without showing this error.