Няма описание
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Data.SqlClient;
  5. using System.Data;
  6. public class SQL_Module : MonoBehaviour
  7. {
  8. public static SqlConnection conn;
  9. public static SqlCommand cmd;
  10. public static SqlDataReader dr;
  11. public static SqlDataAdapter da;
  12. public static string ConString;
  13. public static string SQL1;
  14. public static bool T_SQL;
  15. public static void TestSQL(string TestConString){
  16. using (SqlConnection connection = new SqlConnection(TestConString))
  17. {
  18. try{
  19. connection.Open();
  20. Debug.Log("SQL Connection Successful");
  21. T_SQL=true;
  22. }
  23. catch (SqlException e){
  24. Debug.LogError("SQL Connection Error: " + e.Message);
  25. T_SQL=false;
  26. }
  27. finally{
  28. connection.Close();
  29. }
  30. }
  31. }
  32. public static void ConnOpen_SQL(){
  33. try{
  34. conn.Close();
  35. if (conn.State == ConnectionState.Closed){
  36. conn = new SqlConnection(ConString);
  37. conn.Open();
  38. }
  39. }catch{
  40. conn = new SqlConnection(ConString);
  41. conn.Open();
  42. }
  43. }
  44. public static void CmdSet_For_DGV(){
  45. try{
  46. da = new SqlDataAdapter(SQL1,ConString);
  47. }catch{
  48. }
  49. }
  50. public static void CmdSet_For_dr(){
  51. try{
  52. cmd = conn.CreateCommand();
  53. cmd.CommandText = SQL1;
  54. cmd.Connection = conn;
  55. dr = cmd.ExecuteReader();
  56. }catch{
  57. }
  58. }
  59. }