.net简单的三层实现功能(12)
来源:未知 责任编辑:责任编辑 发表时间:2015-09-16 20:04 点击:次
345 {
346 try
347 {
348 DbConnection connection = GetConnection();
349 DbCommand command = GetCommand(sqlCommand, CommandType.Text, connection);
350 foreach (KeyValuePair<string, object> p in parameters)
351 {
352 command.Parameters.Add(GetParameter(p.Key, p.Value, command));
353 }
354 connection.Open();
355 DbDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
356 command.Parameters.Clear();
357 return reader;
358 }
359 catch (Exception ex)
360 {
361 Console.Write("" + ex.Message);
362 return null;
363 }
364 }
365
366 /// <summary>
367 /// 返回DataTable对象
368 /// </summary>
369 /// <param name="safeSql"></param>
370 /// <returns></returns>
371 public static DataTable GetDataSet(string safeSql)
372 {
373 /*DbProviderFactory _factory = DbProviderFactories.GetFactory(providerName);
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>