码迷,mamicode.com
首页 > 其他好文 > 详细

CommandType.Text

时间:2017-11-20 20:22:15      阅读:110      评论:0      收藏:0      [点我收藏+]

标签:类型   cmd   targe   语句   finally   存储过程   catch   tco   sele   

CommandType.Text代表执行的是SQL语句
CommandType.StoreProcedure代表执行的是存储过程
CommandType代表要执行的类型

//返回DataTable的SQL执行
public DataTable ExecuteDataTable(string cmdText)
{
DataTable dt = new DataTable();

SqlConnection conn = new SqlConnection(connStr);
SqlDataAdapter apt = new SqlDataAdapter(cmdText, conn);
apt.SelectCommand.CommandType = CommandType.Text;
try
{
apt.Fill(dt);
}
catch (Exception exp)
{
throw exp;
}
finally
{
if (conn.State == ConnectionState.Open)
conn.Close();
}
return dt;
}

CommandType.Text

标签:类型   cmd   targe   语句   finally   存储过程   catch   tco   sele   

原文地址:http://www.cnblogs.com/ZkbFighting/p/7867834.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!