帶有引數的command命令形式-----避免文字框中輸入單引號時出錯
阿新 • • 發佈:2019-02-02
SqlConnection sqlcnn = null;
public bool OpenDB() //開啟資料庫的方法
{
sqlcnn = new SqlConnection();
string str = @"server=.\sqlexpress;database=stuInfo111;uid=sa;pwd=yy199455";
sqlcnn.ConnectionString = str;
if (sqlcnn.State == ConnectionState.Closed)
{
sqlcnn.Open();
}
if (sqlcnn.State == ConnectionState.Open)
{
return true;
}
else
{
return false;
}
}
public bool OpenDB() //開啟資料庫的方法
{
sqlcnn = new SqlConnection();
string str = @"server=.\sqlexpress;database=stuInfo111;uid=sa;pwd=yy199455";
sqlcnn.ConnectionString = str;
if (sqlcnn.State == ConnectionState.Closed)
{
sqlcnn.Open();
}
if (sqlcnn.State == ConnectionState.Open)
{
return true;
}
else
{
return false;
}
}