//[1] 변수 선언부
string strCon = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
string strSql = "select * from Food_type order by typ_no desc";
//[2] 커넥션
SqlConnection objCon = new SqlConnection();
objCon.ConnectionString = strCon;
objCon.Open();
//[3] 커멘드
SqlCommand objCmd = new SqlCommand();
objCmd.Connection = objCon;
objCmd.CommandText = strSql;
objCmd.CommandType = CommandType.Text;
//[4] 데이터어댑터
SqlDataAdapter objDa = new SqlDataAdapter();
objDa.SelectCommand = objCmd;
//[5] 데이터셋
DataSet objDs = new DataSet();
objDa.Fill(objDs, "Food_type");
//[6] 그리드뷰 컨트롤
this.GridView1.DataSource = objDs;
this.GridView1.DataBind();
//[7] 마무리
objCon.Close();
반응형
'프로그래밍 > ASP.NET' 카테고리의 다른 글
| macOS 에서 visual studio code를 터미널에서 열기 Big Sur (Catalina 이후버전) (0) | 2021.09.22 |
|---|---|
| Visual Studio(비주얼 스튜디오) 2008, 2010 에서 HTML5 인텔리센스 지원하기 (0) | 2010.09.06 |
| Visual C# 2010 Code Samples (0) | 2010.05.05 |
| Visual C# 2008 Code Samples (0) | 2010.05.05 |
| 비주얼스튜디오 2010 과 .NET 4 릴리스 (0) | 2010.04.15 |