Sql Server Stored Procedure Browser
I have a project that have too many stored procedures. I need to search in procedures too many times. So i made a simple application to browse them easyly source kod and the exe links are below you can download it.
http://hotfile.com/dl/23158895/837faab/SpBrowser-exe.rar.html
http://hotfile.com/dl/23158896/83e7dba/SpBrowser-project.rar.html
code of the appliation
string cnnStr = "Server=.;Database=master;Trusted_Connection=Yes;"; private void Form1_Load(object sender, EventArgs e) { SqlDataAdapter da = new SqlDataAdapter("SELECT [name] FROM [master].[sys].[databases]", cnnStr); DataTable dt = new DataTable(); da.Fill(dt); cbDatabases.DataSource = dt; cbDatabases.DisplayMember = "name"; cbDatabases.ValueMember = "name"; } private void cbDatabases_SelectedIndexChanged(object sender, EventArgs e) { ComboBox mycb = (ComboBox)sender; if (!string.IsNullOrEmpty(mycb.Text) && mycb.Text != "System.Data.DataRowView") { SqlDataAdapter da = new SqlDataAdapter(string.Format(@"USE {0}; SELECT DISTINCT OBJECT_NAME(id) as ad,id FROM syscomments WHERE OBJECTPROPERTY(id, 'IsProcedure') = 1 AND OBJECT_NAME(id) LIKE '%{1}%';", mycb.Text.Trim(), txtCriteria.Text.Trim()), cnnStr); DataTable dt2 = new DataTable(); da.Fill(dt2); lbSp.DataSource = dt2; lbSp.DisplayMember = "ad"; lbSp.ValueMember = "id"; } } private void lbSp_SelectedIndexChanged(object sender, EventArgs e) { ListBox myLb = (ListBox)lbSp; if (myLb.Text != "System.Data.DataRowView") { SqlDataAdapter da = new SqlDataAdapter(string.Format(@"USE {0}; SELECT [text] FROM syscomments WHERE OBJECTPROPERTY(id, 'IsProcedure') = 1 AND OBJECT_NAME(id) = '{1}';", cbDatabases.Text.Trim(), myLb.Text), cnnStr); DataTable dt2 = new DataTable(); da.Fill(dt2); txtSpText.Text = string.Empty; for (int i = 0; i < dt2.Rows.Count; i++) { txtSpText.Text += dt2.Rows[i][0].ToString(); } } } private void txtCriteria_TextChanged(object sender, EventArgs e) { SqlDataAdapter da = new SqlDataAdapter(string.Format(@"USE {0}; SELECT DISTINCT OBJECT_NAME(id) as ad,id FROM syscomments WHERE OBJECTPROPERTY(id, 'IsProcedure') = 1 AND (OBJECT_NAME(id) LIKE '%{1}%' OR [text] LIKE '%{1}%');", cbDatabases.Text.Trim(), txtCriteria.Text.Trim()), cnnStr); DataTable dt2 = new DataTable(); da.Fill(dt2); lbSp.DataSource = dt2; lbSp.DisplayMember = "ad"; lbSp.ValueMember = "id"; }








