123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using System.Data.SqlClient;
- using System.Data;
-
- public class SQL_Module : MonoBehaviour
- {
- public static SqlConnection conn;
- public static SqlCommand cmd;
- public static SqlDataReader dr;
- public static SqlDataAdapter da;
- public static string ConString;
- public static string SQL1;
- public static bool T_SQL;
-
- public static void TestSQL(string TestConString){
- using (SqlConnection connection = new SqlConnection(TestConString))
- {
- try{
- connection.Open();
- Debug.Log("SQL Connection Successful");
- T_SQL=true;
- }
- catch (SqlException e){
- Debug.LogError("SQL Connection Error: " + e.Message);
- T_SQL=false;
- }
- finally{
- connection.Close();
- }
- }
- }
- public static void ConnOpen_SQL(){
- try{
- conn.Close();
- if (conn.State == ConnectionState.Closed){
- conn = new SqlConnection(ConString);
- conn.Open();
- }
- }catch{
- conn = new SqlConnection(ConString);
- conn.Open();
- }
-
- }
-
- public static void CmdSet_For_DGV(){
- try{
- da = new SqlDataAdapter(SQL1,ConString);
- }catch{
-
- }
- }
-
- public static void CmdSet_For_dr(){
- try{
- cmd = conn.CreateCommand();
- cmd.CommandText = SQL1;
- cmd.Connection = conn;
- dr = cmd.ExecuteReader();
- }catch{
- }
- }
-
- }
|