블로그 이미지
Magic_kit
study 관련자료를 한곳으로 자기 개발 목적으로 재태크 재무 관리 목적으로 일상생활의 팁을 공유 하기 위하여 블로그를 개설 하였습니다.

calendar

1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
반응형

Category

Recent Post

Recent Comment

Archive

2009. 9. 30. 15:51 .Net Project/ADO.NET 3.5
반응형

 


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Winbinding
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            //초기화자
            InitializeComponent();
        }

        private DataSet ds; //주수록 담을 그릇 (전역변수) 필드 선언
        private void Form1_Load(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection
          
         ("server=.;database=AddressBook;uid=AddressBook;pwd=1234");

            SqlCommand cmd = new SqlCommand
                          ("Select *From AddressBook", con);

            SqlDataAdapter da = new SqlDataAdapter(cmd);

            ds = new DataSet();
            da.Fill(ds, "AddressBook"); //채우기

//[!]바인딩
//text1의 Text속성을  ds 에 담겨 있는 AddressBook 테이블의 Name필드 연결
 
         textBox1.DataBindings.Add("Text", ds, "AddressBook.Name");
         textBox2.DataBindings.Add("Text", ds, "AddressBook.Mobile");
         textBox3.DataBindings.Add("Text", ds, "AddressBook.Email");

        }
        //이전
        private void button1_Click(object sender, EventArgs e)
        {
           //감소
            BindingContext[ds, "AddressBook"].Position--; //레코드 이동

        }
        //다음
        private void button2_Click(object sender, EventArgs e)
        {
            //증가 
            BindingContext[ds, "AddressBook"].Position++; //다음 레코드
        }
    }
}









반응형
posted by Magic_kit