public string GetData()
{
try
{
SqlConnection sqlConnection =
new SqlConnection(
"Data Source=127.0.0.1;Initial Catalog=SalesERPDB;Integrated Security=True;User Id=sa;Password=123456");
sqlConnection.Open();
SqlCommand sqlCommand = new SqlCommand();
sqlCommand.Connection = sqlConnection;
sqlCommand.CommandType = CommandType.Text;
sqlCommand.CommandText = "select FirstName from TblEmployee";
return sqlCommand.ExecuteScalar().ToString();
}
catch (Exception ex)
{
return ex.ToString();
}
}
C#连接SQLServer数据库
最新推荐文章于 2024-08-15 09:49:33 发布