SQL连接数据库
时间:2021-07-01 10:21:17
帮助过:15人阅读
;
string conString =
"Data Source=; Initial Catalog=数据库名;User ID=账户;Password=密码";
//连接数据库的字符串
conn =
new SqlConnection(conString);
conn.Open();//打开数据库连接
if (conn.State ==
ConnectionState.Open)
{
// Console.WriteLine("数据库连接成功");
}
string sql =
"SELECT * FROM LE_Calibration WHERE mo=‘M0PWP2SMA01001‘";
SqlDataAdapter da =
new SqlDataAdapter(sql, conn);
//从数据库中查询
conn.Close();
DataSet ds =
new DataSet();
da.Fill(ds, "product");
//将数据填充到DataSet
DataTable myTable = ds.Tables[
"product"];
SQL连接数据库
标签:数据 user 账户 string code 成功 ble source initial