using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string str1 = "Data Source=.;Initial Catalog=aaa;Integrated Security=True";
private void Form1_Load(object sender, EventArgs e)
{
}
public bool control_2() //全局方法
{
string str1 = "Data Source=.;Initial Catalog=aaa;Integrated Security=True";
String sql = "select name from sysobjects where Xtype='p' and name='p13'";
SqlConnection a = new SqlConnection(str1);
SqlCommand com= new SqlCommand(sql, a);
a.Open();
SqlDataReader i = com.ExecuteReader();
if (i.HasRows)
{
return true;
}
else
{
return false;
}
a.Close();
}
private void button1_Click(object sender, EventArgs e)
{
if (control_2()==true)
{
SqlConnection a = new SqlConnection(str1);