学习过程中 遇到的一些东西,自勉

this.textBox1.AppendText(v.ToString() + "\r\n");//换行显示
*******************************************************************************
this.label2.Text = v.ToString();
label2.Refresh(); //强制刷新 方法对ListBox等多种控件都有效
*******************************************************************************

 

连接SQLserver的代码

 

public DataSet SelectDataSetHIS(string sql)
{
int retryCounter = 0;//尝试重新连接
retry:
try
{
string strCon = "server = 127.0.0.1; database = ***; user id = sa; password = 123456; Packet Size = 1433; Persist Security Info = True";
SqlConnection conn = new SqlConnection(strCon);
conn.Open();

SqlDataAdapter sqld = new SqlDataAdapter(sql, strCon);
DataSet ds = new DataSet();
sqld.Fill(ds);
return ds;
}
catch (Exception e)
{

retryCounter++;
if (retryCounter < 2)
goto retry;
return null;
}
}

posted on 2017-10-19 17:25  天空的太阳  阅读(111)  评论(0编辑  收藏  举报

导航