C#中如何判断一个SQL存储过程是否存在? 如题,谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select 1 from dbo.sysobjects t where t.name='存储过程名字' dbo.sysobjects 是系统表吗?在sql 2005中怎么没找到? public static bool IsStoredProcExisting(SqlConnection conn, string procName) { bool result = false; conn.Open(); SqlCommand command = conn.CreateCommand(); command.CommandText = "SELECT name FROM sysobjects WHERE xtype = 'P' and name = @name"; command.Parameters.Add("@name", procName); object temp = command.ExecuteScalar(); result = temp != null; conn.Close(); return result; } 运行到:object temp = command.ExecuteScalar();出错提示:列名 'procName' (存储过程名)无效。什么原因哦? public static bool IsStoredProcExisting(SqlConnection conn, string procName) { bool result = false; conn.Open(); SqlCommand command = conn.CreateCommand(); command.CommandText = "SELECT name FROM sysobjects WHERE xtype = 'P' and name = @name"; command.Parameters.Add("@name", procName); object temp = command.ExecuteScalar(); result = temp != null; conn.Close(); return result; }这个就可以了 C#有没有提供让用户输入一个实数的对话框 模拟键盘做个@符号输入 C#在实际应用中做什么呢 C# 在调用Acrobat.dll使PDF文件转换为JPG文件后,JPG文件的分辨率缩小了 字符串转成日期时间的问题 多线程问题,,请各位帮忙看看,,!!! 串口问题 C#如何执行多条dos指令 webBrowser使用多线程问题 为何我的任务管理器的应用进程中老有个Desktop Set在运行,使我的机器非常慢?请大侠指点 console.writeline();的问题,谢谢 System.NullReferenceException: 未将对象引用设置到对象的实例。
{
bool result = false;
conn.Open();
SqlCommand command = conn.CreateCommand();
command.CommandText = "SELECT name FROM sysobjects WHERE xtype = 'P' and name = @name";
command.Parameters.Add("@name", procName);
object temp = command.ExecuteScalar();
result = temp != null;
conn.Close();
return result;
}
{
bool result = false;
conn.Open();
SqlCommand command = conn.CreateCommand();
command.CommandText = "SELECT name FROM sysobjects WHERE xtype = 'P' and name = @name";
command.Parameters.Add("@name", procName);
object temp = command.ExecuteScalar();
result = temp != null;
conn.Close();
return result;
}
这个就可以了