daily pastebin goal
15%
SHARE
TWEET

Untitled

a guest Apr 27th, 2018 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Threading;
  3. using System.Data;
  4. using MySql.Data.MySqlClient;
  5. using NWN;
  6. using System.Configuration;
  7.  
  8. namespace NWN.Scripts
  9. {
  10.     public class sql_async_query
  11.     {
  12.         static public int Main ()
  13.         {
  14.             //Console.WriteLine("Hello World!");
  15.             Thread query_thread = new Thread(RunQuery);
  16.             //query_thread.Start("INSERT INTO players (id, name) VALUES (0, 'John');");
  17.             query_thread.Start(NWScript.GetLocalString(Object.OBJECT_SELF, "sql"));
  18.             return 1;
  19.         }
  20.  
  21.         static public void RunQuery(object _query)
  22.         {
  23.             string query = _query as string;
  24.  
  25.             string connectionString =
  26.               "encrypt=false;" +
  27.               "database=potm;" +
  28.               "user=potm;" +
  29.               "password=potmtest;" +
  30.               "pooling=false";
  31.  
  32.             IDbConnection dbcon;
  33.             dbcon = new MySqlConnection(connectionString);
  34.             dbcon.Open();
  35.             IDbCommand dbcmd = dbcon.CreateCommand();
  36.  
  37.             dbcmd.CommandText = query;
  38.  
  39.             dbcmd.ExecuteNonQuery();
  40.  
  41.             dbcmd.Dispose();
  42.             dbcmd = null;
  43.             dbcon.Close();
  44.             dbcon = null;
  45.         }
  46.     }
  47. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top