The following C# code explains you that whether the entered search string is available in any stored procedure of current database or not?
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox runat="server" ID="txtsearch" />
<asp:Button Text="Search" runat="server" ID="btnSearch" onclick="btnSearch_Click" /><br />
<asp:Label Text="" runat="server" ID="lblFb" ForeColor="Blue" />
</div>
</form>
</body>
</html>
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSearch_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source=SDW2249; Initial Catalog=MedChive; User Id=testLogin; Password=span@1234");
if (conn.State == ConnectionState.Closed)
{
conn.Open();//error shows here The ConnectionString property has not been initialized.
}
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT DISTINCT o.name AS Object_Name,o.type_desc FROM sys.sql_modules m INNER JOIN sys.objects o ON m.object_id=o.object_id WHERE m.definition Like '%" +txtsearch.Text+"%'";
SqlDataReader dReader = cmd.ExecuteReader();
if (dReader.HasRows == true)
{
lblFb.Text = "Procedure with search string is existed";
}
else
{
lblFb.Text = "Procedure with search string is NOT existed";
}
}
EDIT: Hi Prathap, Have you checked the above solution?
Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif
Jprathap, if this helps please login to Mark As Answer. | Alert Moderator