第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

我寫了一個靜態(tài)數(shù)據(jù)連接類 但是不知道 怎么處理其中的對象

我寫了一個靜態(tài)數(shù)據(jù)連接類 但是不知道 怎么處理其中的對象

長風秋雁 2018-12-06 13:45:29
1 using System; 2 using System.Data; 3 using System.Configuration; 4 using System.Collections; 5 using System.Web; 6 using System.Web.Security; 7 using System.Data.SqlClient; 8 using System.Web.UI; 9 using System.Web.UI.HtmlControls; 10 using System.Web.UI.WebControls; 11 using System.Web.UI.WebControls.WebParts; 12 13 /// <summary> 14 ///database 的摘要說明 15 /// </summary> 16 public static class sqlbase 17 { 18 19 static SqlConnection thiscon2;//處理函數(shù)使用的鏈接 20 static string constr1; 21 22 public static string constr2 = ConfigurationManager.ConnectionStrings["data_smfConnectionString"].ToString(); 23 static SqlCommand com,com1,com2,com3 ; 24 static SqlDataAdapter adpater; 25 static DataSet ds; 26 static String rtstr; 27 /// <summary> 28 /// 數(shù)據(jù)連接字符串 29 /// </summary> 30 /// <param name="_sqlstr"></param> 31 static sqlbase() 32 { 33 sqlconstr1(); 34 35 } 36 /// <summary> 37 /// 使用默認1鏈接 38 /// </summary> 39 public static void sqlconstr1() 40 { 41 constr1 = ConfigurationManager.ConnectionStrings["playerConnectionString"].ToString(); 42 } 43 /// <summary> 44 /// 使用默認2鏈接 45 /// </summary> 46 public static void sqlconstr2() 47 { 48 constr1 = constr2; 49 } 50 51 public static void getcon() 52 { 53 54 thiscon2= new SqlConnection(constr1); 55 56 } 57 public static SqlCommand getcom() 58 { 59 60 com= new SqlCommand(); 61 return com; 62 63 } 64 #region p_sqldatabase 成員 65 66 /// <summary> 67 /// 通過SQL語句返回特定數(shù)據(jù) 68 /// </summary> 69 /// <param name="str"></param> 70 /// <returns></returns> 71 public static DataSet gettable(String str) 72 { 73 getcon(); 74 com1 = getcom(); 75 com1.Connection = thiscon2; 76 com1.CommandText = str; 77 adpater = new SqlDataAdapter(com); 78 ds = new DataSet(); 79 adpater.Fill(ds); 80 closecom(ref com3); 81 return ds; 82 } 83 84 /// <summary> 85 /// 通過存儲過程返回特定數(shù)據(jù) 86 /// </summary> 87 /// <param name="ay"></param> 88 /// <param name="StoredProcedurename"></param> 89 /// <returns></returns> 90 public static DataSet gettable(SqlParameter[] pter, String StoredProcedurename) 91 { 92 getcon(); 93 com2 = getcom(); 94 com2.Connection = thiscon2; 95 com2.Parameters.Clear(); 96 com2.CommandType = CommandType.StoredProcedure; 97 com2.CommandText = StoredProcedurename; 98 com2.Parameters.AddRange(pter); 99 adpater = new SqlDataAdapter(com);100 ds = new DataSet();101 adpater.Fill(ds);102 closecom(ref com3);103 return ds;104 }105 106 public static int todo(string str)107 {108 109 throw new NotImplementedException();110 }111 112 public static int todo(SqlParameter[] pter, string StoredProcedurename)113 {114 throw new NotImplementedException();115 }116 117 public static string getone(string str)118 {119 throw new NotImplementedException();120 }121 122 public static string getone(SqlParameter[] pter, string StoredProcedurename)123 {124 try125 {126 getcon();127 com3 = getcom();128 com3.Connection = thiscon2;129 com3.Connection.Open();130 com3.CommandType = CommandType.StoredProcedure;131 com3.Parameters.Clear();132 com3.Parameters.AddRange(pter);133 com3.CommandText = StoredProcedurename;134 rtstr = com.ExecuteScalar().ToString();135 closecom(ref com3);136 137 return rtstr;138 }139 catch (Exception e)140 {141 closecom(ref com3);142 errormark.strong(e);143 return "-1";144 }145 146 147 }148 149 public static void closecom(ref SqlCommand comclose)150 {151 152 if (comclose != null)153 {154 comclose.Connection.Close();155 comclose.Connection.Dispose();156 comclose.Dispose();157 158 }159 160 }161 /// <summary>162 /// 設(shè)置鏈接字符串163 /// </summary>164 public static string setsqlcon165 {166 set167 {168 constr1 = value; sqlconstr1();169 170 }171 172 }173 174 #endregion175 176 177 public static void gettable()178 {179 throw new NotImplementedException();180 }181 }
查看完整描述

4 回答

?
侃侃無極

TA貢獻2051條經(jīng)驗 獲得超10個贊

不會,用戶之間是不會影響的,重載方法會根據(jù)傳入的參數(shù)調(diào)用對應(yīng)的方法。

查看完整回答
反對 回復 2019-01-21
?
汪汪一只貓

TA貢獻1898條經(jīng)驗 獲得超8個贊

我寫的那是靜態(tài)的你沒看到?
查看完整回答
反對 回復 2019-01-21
?
泛舟湖上清波郎朗

TA貢獻1818條經(jīng)驗 獲得超3個贊

不要這樣寫??紤]下線程安全問題。

查看完整回答
反對 回復 2019-01-21
  • 4 回答
  • 0 關(guān)注
  • 369 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號