📄 citys.cs
字号:
using System;
using System.Data.SqlClient;
using System.Data;
namespace Air.Class
{
using Air.entity;
/// <summary>
/// Citys 的摘要说明。
/// </summary>
public class Citys
{
public Citys()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public CityData GetAllCity()
{
SqlConnection sqlConnection = new SqlConnection();
sqlConnection.ConnectionString =
"workstation id=YAOYANG;packet size=4096;user id=sa;data source=\"YAOYANG\\yaoyang\";"
+ "persist security info=True;initial catalog=AirTicket;password=510902";
SqlDataAdapter sqlDataAdapter = new SqlDataAdapter();
SqlCommand sqlCommand = new SqlCommand();
sqlDataAdapter.SelectCommand = sqlCommand;
sqlCommand.CommandText = "SelectCity";
sqlCommand.CommandType = CommandType.StoredProcedure;
sqlCommand.Connection = sqlConnection;
CityData city = new CityData();
try
{
sqlConnection.Open();
sqlDataAdapter.Fill(city.City);
}
catch(Exception e)
{
throw new ApplicationException("数据库访问错误。", e);
}
finally
{
sqlConnection.Close();
}
return city;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -