.net简单的三层实现功能(8)
来源:未知 责任编辑:责任编辑 发表时间:2015-09-16 20:04 点击:次
190 {
191 using (DbConnection connection = GetConnection())
192 {
193 DbCommand command = GetCommand(cmdText, CommandType.Text, connection);
194 connection.Open();
195 object val = command.ExecuteScalar();
196 command.Parameters.Clear();
197 return val;
198 }
199 }
200
201 /// <summary>
202 /// 执行有返回值有参数的sql语句
203 /// </summary>
204 /// <param name="cmdText"></param>
205 /// <param name="para"></param>
206 /// <returns></returns>
207 public static object ExecuteScalar(string cmdText, Dictionary<string, object> para)
208 {
209 using (DbConnection connection = GetConnection())
210 {
211 DbCommand command = GetCommand(cmdText, CommandType.Text, connection);
212 foreach (KeyValuePair<string, object> p in para)
213 {
214 command.Parameters.Add(GetParameter(p.Key, p.Value, command));
215 }
216 connection.Open();
217 object val = command.ExecuteScalar();
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>