아래는 addrbook 이라는 테이블의 tel, name 컬럼중...
text에 name, value에 tel을 매핑 시키는 예 입니다.
(DataAdapter를 사용하지 않았습니다.)
private void Page_Load(object sender, System.EventArgs e)
{
string ConStr = ("server=(local);uid=sa;pwd=pass;database=pubs");
SqlConnection Conn = new SqlConnection(ConStr);
Conn.Open();
string sql = "select name, tel from addrbook ";
SqlCommand myCommand = new SqlCommand(sql, Conn);
SqlDataReader myReader = myCommand.ExecuteReader();
int i=0;
DropDownList1.DataSource = myReader;
DropDownList1.DataValueField = "tel";
DropDownList1.DataTextField = "name";
DropDownList1.DataBind();
}
text에 name, value에 tel을 매핑 시키는 예 입니다.
(DataAdapter를 사용하지 않았습니다.)
private void Page_Load(object sender, System.EventArgs e)
{
string ConStr = ("server=(local);uid=sa;pwd=pass;database=pubs");
SqlConnection Conn = new SqlConnection(ConStr);
Conn.Open();
string sql = "select name, tel from addrbook ";
SqlCommand myCommand = new SqlCommand(sql, Conn);
SqlDataReader myReader = myCommand.ExecuteReader();
int i=0;
DropDownList1.DataSource = myReader;
DropDownList1.DataValueField = "tel";
DropDownList1.DataTextField = "name";
DropDownList1.DataBind();
}
| 12-27 | 2878 | |||
| 12-11 | 2098 | |||
| 53 | 03-15 | 1955 | ||
| 52 | 01-31 | 2093 | ||
| 51 | 01-31 | 3063 | ||
| 50 | 01-31 | 1617 | ||
| 49 | 01-19 | 1941 | ||
| 48 | 01-11 | 1808 | ||
| 47 | 01-03 | 2414 | ||
| 46 | 12-27 | 2878 | ||
| 45 | 12-19 | 2021 | ||
| 44 | 12-14 | 1988 | ||
| 43 | 12-11 | 2098 | ||
| 42 | 12-09 | 1632 | ||
| 41 | 12-01 | 1853 | ||
| 40 | 12-01 | 2098 | ||
| 39 | 12-01 | 1505 | ||
댓글 없음:
댓글 쓰기