📄 citys.cs
字号:
using System;
using System.Data.SqlClient;
using System.Data;
using AirQuery.entity;
//该源码下载自www.51aspx.com(51aspx.com)
namespace AirQuery.Class
{
/// <summary>
/// Citys 的摘要说明。
/// </summary>
public class Citys
{
public Citys()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public CityData GetAllCity()
{
SqlConnection sqlConnection = new SqlConnection();
sqlConnection.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];//"server=localhost;uid=sa;pwd=;database=AirQuery;";
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 + -