private void Set_SERVICE_Load(object sender, EventArgs e)
{
            string connectionString = "server=localhost;database=[데이타베이스이름];uid=[아이디];pwd=[패쓰워드]";

            SqlConnection myConnection = new SqlConnection(connectionString);

            string commandString = "select * from Parts_Codes";

            SqlCommand myCommand = new SqlCommand();
            myCommand.Connection = myConnection; // 실행할 서버, DB 지정
            myCommand.CommandText = commandString;  // 실행할 쿼리지정

            myConnection.Open(); // DataBase 오픈

            SqlDataReader myReader = myCommand.ExecuteReader();
            while (myReader.Read())
            {
                Lstbox_PartsCode.Items.Add(myReader[0].ToString());             }
}

+ Recent posts